bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: realloc buggy?


From: Simon Josefsson
Subject: Re: realloc buggy?
Date: Thu, 01 Jun 2006 12:51:37 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

Paul Eggert <address@hidden> writes:

> Simon Josefsson <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]