Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Nov 2002 15:32:46 +0000
From:      David Malone <dwmalone@maths.tcd.ie>
To:        Marc Recht <marc@informatik.uni-bremen.de>
Cc:        freebsd-current@FreeBSD.ORG
Subject:   Re: malloc(0) broken?
Message-ID:  <20021122153246.GA73734@walton.maths.tcd.ie>
In-Reply-To: <79620000.1037978720@leeloo.intern.geht.de>
References:  <79620000.1037978720@leeloo.intern.geht.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Nov 22, 2002 at 04:25:20PM +0100, Marc Recht wrote:
> Hi!
> 
> A malloc(0) returns always 0x800 on my system. This causes some third-party 
> software to fail, because they expect malloc(0) to return NULL. Is this a 
> bug or a feature? malloc(3) doesn't mention anything.

Feature in malloc and bug in third-party code. C99 says:

	If the size of the space requested is zero, the behavior
	is implimentation defined: either a null pointer is returned,
	or the behavior is as if the size were some nonzero value,
	except that the returned pointer shall not be used to access
	an object.

Also see the V flag listed in malloc(3).

	David.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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