alx-0029r4 - Restore the traditional realloc(3) specification
Alejandro Colomar
alx@kernel.org
Wed Jun 25 18:21:48 GMT 2025
Hi Wilco,
On Wed, Jun 25, 2025 at 06:07:06PM +0000, Wilco Dijkstra wrote:
> In principle a realloc that shrinks a non-NULL block does never need to fail.
> If it can't shrink the current block (either because internal design means it
> can't make it any smaller or because it doesn't have memory for a new
> smaller block) then it should preferably return the original pointer instead
> of returning NULL and taking the failure path.
>
> So I'm wondering whether we should more clearly specify this - whenever
> it's possible to not fail, don't return NULL?
As Rich Felker said, musl has very good reasons for failing, several of
them. Look at his comments in the thread.
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250625/5c69f18e/attachment-0001.sig>
More information about the Libc-alpha
mailing list