[Andrew Pimlott <pimlott@abel.MATH.HARVARD.EDU>] realloc(p, 0) vs. free

Wolfram Gloger wmglo@dent.med.uni-muenchen.de
Wed Apr 28 15:06:00 GMT 1999


> Whether or not this is technically a bug, completely freeing the memory 
> on realloc(p, 0) seems the obviously preferred behavior.  Is there any 
> reason for keeping the current behavior?

Well, as the comment in the source says, when malloc(0) returns a
unique pointer (like it does currently in glibc) it seems consistent
that realloc(...,0) does so too.  So, if the standard really requires
that realloc(...,0) frees then we should also consider changing
malloc(0) to return NULL IMHO.

Regards,
Wolfram.
-- 
`Surf the sea, not double-u three...'
wmglo@dent.med.uni-muenchen.de



More information about the Libc-alpha mailing list