This is the mail archive of the
libc-alpha@cygnus.com
mailing list for the glibc project.
Re: [Andrew Pimlott <pimlott@abel.MATH.HARVARD.EDU>] realloc(p, 0) vs. free
- To: Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
- Subject: Re: [Andrew Pimlott <pimlott@abel.MATH.HARVARD.EDU>] realloc(p, 0) vs. free
- From: tb@MIT.EDU (Thomas Bushnell, BSG)
- Date: 02 May 1999 16:20:46 -0400
- Cc: libc-alpha@cygnus.com
- References: <199905011551.LAA00447@sleipnir.valparaiso.cl>
Horst von Brand <vonbrand@sleipnir.valparaiso.cl> writes:
> tb@MIT.EDU (Thomas Bushnell, BSG) said:
> > Roland McGrath <roland@frob.com> writes:
> > > The only thing that is optional is whether malloc(0) returns null or
> > > a block that can be freed.
>
> > And let's be clear that while it's permissible under ANSI C for
> > malloc(0) to return null, any sane system returns a unique pointer
> > that can be freed.
>
> free(NULL) can do exactly nothing, so this is wholy under libc's
> control. No sane C program would arbitrarily assume more than ANSI
> provides, anyway.
That's ludicrous! I write programs that assume they are under glibc,
because they use many other features that only exist on glibc. It's
reasonable for such a program to know that glibc specifies malloc(0)
more tightly too.
Thomas