bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] GNUlib realloc POSIX comformance


From: Paul Eggert
Subject: Re: [Bug-gnulib] GNUlib realloc POSIX comformance
Date: Wed, 17 Nov 2004 15:00:54 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Yoann Vandoorselaere <address@hidden> writes:

> GNUlib realloc won't free the pointer ever if the provided size is zero. 

Now that I've fixed the unlikely bug, it always has the effect of
freeing the pointer.

> As I understand it, rpl_realloc will replace the regular realloc call,
> in order to provide consistant behavior, but it itself depend on the
> regular libc provided realloc() call. Or am I missing something ?

No, you're correct.

The POSIX rules are a bit subtle in this area.  For example, an
implementation that ignores "free (p)" (i.e., treats it as a no-op)
would conform to POSIX (albeit with a memory leak).  Similarly,
yesterday's (unfixed) version of gnulib realloc conformed to POSIX
(albeit with a memory leak in unlikely circumstances).

As far as style and so forth: the realloc, malloc, and calloc modules
are for GNU apps and for convenience they support the GNU semantics,
which are slight extensions to POSIX.  I suppose we could have
realloc-nongnu etc modules that lacked those extensions, but it's
probably not worth the hassle.




reply via email to

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