[musl] realloci(): A realloc() variant that works in-place
Collin Funk
collin.funk1@gmail.com
Thu Oct 30 23:35:55 GMT 2025
"A. Wilcox" <AWilcox@Wilcox-Tech.com> writes:
>> - We could perfectly return int (0 for success, -1 for error),
>> but returning the pointer makes it a drop-in replacement for
>> realloc(3), and also allows using it in chained code
>>
>> foo(realloci(p, size));
>
>
> This is never safe if `realloci` can return `NULL`, IMO.
This was my concern as well. The code looks nicer than a normal realloc,
but I think it will lead to more people not checking for allocation
failures. I would rather have a nice error message than a segmentation
fault when a program fails to allocate memory.
Collin
More information about the Libc-alpha
mailing list