[musl] Re: realloci(): A realloc() variant that works in-place
Rich Felker
dalias@libc.org
Mon Nov 10 01:20:23 GMT 2025
On Sun, Nov 09, 2025 at 11:03:52AM -0800, Paul Eggert wrote:
> On 2025-11-09 10:11, Rich Felker wrote:
> > On Sun, Nov 09, 2025 at 06:38:25PM +0100, Alejandro Colomar wrote:
>
> > > My point was that it's easier to consider the lifetime of P ends at
> > > every realloc(3) call than to consider it to end only if Q!=P.
> >
> > I agree with this.
>
> ? The lifetime of P does not necessarily end after Q=realloc(P,N), even in
> C23. So the situation is already more complicated than Alejandro's incorrect
> summary, and for good reason. And there should be nothing wrong with
> adjusting this part of the standard to better reflect how real-world
> implementations behave.
The only way the lifetime of P does not end is if realloc returns a
null pointer indicating failure. On success, it is as if
malloc+memcpy+free.
Rich
More information about the Libc-alpha
mailing list