[musl] Re: realloci(): A realloc() variant that works in-place

Rich Felker dalias@libc.org
Tue Nov 11 22:45:45 GMT 2025


On Tue, Nov 11, 2025 at 01:59:19PM -0800, Thiago Macieira wrote:
> On Tuesday, 11 November 2025 12:51:28 Pacific Standard Time Rich Felker wrote:
> > What is the actual problem folks are trying to solve?
> > 
> > Has that ever been stated clearly?
> 
> Yes, more than once: growing a container (array, usually) that holds objects 
> with non-trivial copy/move operations. realloc() is unsuitable for that 
> because the elements can't be memmove()d, so containers today must allocate a 
> new buffer, perform the expensive move, then free the old buffer.

And that's still going to happen. The only difference is the exact
thresholds at which it happens, and having slightly less memory
overhead along the way. If the problem is "moving objects is expensive
and we don't want to do that", nothing on this path does anything to
solve it.

Rich


More information about the Libc-alpha mailing list