From: René Scharfe Date: Sun, 18 Jan 2026 14:55:23 GMT Subject: Re: [PATCH 01/10] ivec: introduce the C side of ivec Message-ID: <5c7e853d-f368-4d8a-a5f0-f4d485c1c3d6@web.de> In-Reply-To: On 1/17/26 4:58 PM, Ezekiel Newren wrote: > On Fri, Jan 16, 2026 at 1:19 PM René Scharfe wrote: >> >>> +void ivec_reserve(void *self_, size_t additional) >>> +{ >>> + struct IVec_c_void *self = self_; >>> + >>> + size_t growby = 128; >>> + if (self->capacity > growby) >>> + growby = self->capacity; >>> + if (additional > growby) >>> + growby = additional; >>> + >>> + _set_capacity(self, self->capacity + growby); >>> +} >> >> Constant growth steps like these cause linear growth and quadratic >> complexity. ALLOC_GROW does exponential growth with factor 1.5 to >> get linear complexity. Here's an old plea to do the same: >> https://blog.mozilla.org/nnethercote/2014/11/04/please-grow-your-buffers-exponentially/ >> >> René > > It _is_ exponential. ivec_reserve(&vec, 1) means grow by _at least_ 1. D'oh! Right, it grows with factor 2, as growby is at least as big as ->capacity. I can't read. René