Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Jun 2006 23:56:21 +0200
From:      joerg@britannica.bec.de
To:        freebsd-hackers@freebsd.org
Subject:   Re: Return value of malloc(0)
Message-ID:  <20060628215621.GC18893@britannica.bec.de>
In-Reply-To: <20060628181045.GA54915@curry.mchp.siemens.de>
References:  <20060628181045.GA54915@curry.mchp.siemens.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jun 28, 2006 at 08:10:45PM +0200, Andre Albsmeier wrote:
> (Now malloc returns NULL and firefox doesn't interpret the
> result as a pointer to some allocated memory and therefore
> doesn't use it).

Return NULL for malloc(0) is one of two possible implementations. The
other behaviour is to generate a unique pointer for each call. Both
behaviours are intentionally allowed by the standard and code making
assumptions about either is broken.

It should be added that returning NULL for malloc(0) is consistent with
realloc, so it is actually nicer.

Joerg



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060628215621.GC18893>