This is the mail archive of the
mailing list for the glibc project.
Re: [Andrew Pimlott <pimlott@abel.MATH.HARVARD.EDU>] realloc(p, 0) vs. free
- To: email@example.com
- Subject: Re: [Andrew Pimlott <pimlott@abel.MATH.HARVARD.EDU>] realloc(p, 0) vs. free
- From: Wolfram Gloger <firstname.lastname@example.org>
- Date: 28 Apr 1999 22:06:03 -0000
- CC: email@example.com, pimlott@abel.MATH.HARVARD.EDU
- References: <firstname.lastname@example.org>
> 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.
`Surf the sea, not double-u three...'