This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]