|
|
Message-ID: <2oth3faxpbkqnqjgypwk2cf6sver6zl4noqkwmou3lxqhk6g2v@235gx4eqpdnj>
Date: Sun, 9 Nov 2025 20:16:42 +0100
From: Alejandro Colomar <alx@...nel.org>
To: Paul Eggert <eggert@...ucla.edu>
Cc: Rich Felker <dalias@...c.org>, libc-alpha@...rceware.org,
musl@...ts.openwall.com, "A. Wilcox" <AWilcox@...cox-tech.com>,
Lénárd Szolnoki <cpp@...ardszolnoki.com>, Collin Funk <collin.funk1@...il.com>,
Arthur O'Dwyer <arthur.j.odwyer@...il.com>, Jonathan Wakely <jwakely@...hat.com>,
"Paul E. McKenney" <paulmck@...nel.org>, Thiago Macieira <thiago@...ieira.org>
Subject: Re: Re: realloci(): A realloc() variant that works in-place
Hi Paul,
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.
My reading of ISO C23 is that the lifetime of both the object and the
pointer are unconditionally terminated by realloc(3). A new object is
created, whose contents are the same as those of the old object, but
it's an entirely new object, with a new lifetime.
The realloc function
deallocates the old object pointed to by ptr
and returns a pointer to a new object
that has the size specified by size.
The contents of the new object
shall be the same as that of the old object prior to deallocation,
up to the lesser of the new and old sizes.
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.