glibc realloc(ptr, 0) vs. C17 specification
DJ Delorie
dj@redhat.com
Tue Aug 6 19:58:00 GMT 2019
for realloc(ptr, 0), I read it this way:
> If size is zero and memory for the new object is not allocated, it is
> implementation-defined whether the old object is deallocated.
We define it as "the old object is deallocated"
> The realloc function returns a pointer to the new object (which may have
> the same value as a pointer to the old object), or a null pointer if the
> new object has not been allocated.
We return a NULL poiner as a new object is not allocated.
> C17 7.31.12 Invoking realloc with a size argument equal to zero is an
> obsolescent feature.
And the user shouldn't be doing this anyway.
I don't see where the conflict is. Am I missing something?
More information about the Libc-alpha
mailing list