memory leak or something wrong

Brandon Black blblack at
Tue Jun 19 00:04:34 CEST 2012

On Mon, Jun 18, 2012 at 4:50 PM, Brandon Black <blblack at> wrote:
> However, whether it's a
> simple bug or somehow intentional behavior is unclear to me given all
> that arguing about malloc(p,0) between glibc/C/POSIX people.

Shortly after the last email, I noticed the realloc() docs in Fedora
16 contain this sentence about realloc():

"If size was equal to 0, either NULL or a pointer suitable to be
passed to free() is returned."

Sure enough, realloc(p, 0) returns a non-NULL pointer, and free(p) of
that return value also stops the leak.  Another summary of some of the
differences of interpretation going on here: .
IMHO, in a world with that kind of mess going on, the new "safe"
behavior for portable code may just be to never use realloc(p,0)
because you can't trust what it means :(

-- Brandon

More information about the libev mailing list