This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: glibc realloc(ptr, 0) vs. C17 specification
- From: DJ Delorie <dj at redhat dot com>
- To: Eric Blake <eblake at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 06 Aug 2019 15:58:04 -0400
- Subject: Re: glibc realloc(ptr, 0) vs. C17 specification
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?