Paul Eggert <[EMAIL PROTECTED]> writes:

> Simon Josefsson <[EMAIL PROTECTED]> writes:
>
>> What about this instead?
>
> Unfortunately that is buggy too, if the goal is to emulate glibc.
> With glibc, if p is not null, realloc (p, 0) always returns NULL.

And free's p, presumably?

> Conversely, realloc (NULL, 0) is equivalent to malloc (0) and
> typically returns non-NULL.  It is kind of confusing.

Yes, quite confusing.  It's a bad that the libc manual doesn't discuss
the semantics for NEWSIZE==0, so the behaviour you describe is not
documented as far as I can tell.

The glibc behaviour here seems like something we shouldn't encourage
IMHO.

/Simon


Reply via email to