From owner-freebsd-current Fri Nov 22 7:32:52 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0DFC537B401 for ; Fri, 22 Nov 2002 07:32:51 -0800 (PST) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by mx1.FreeBSD.org (Postfix) with SMTP id C31FE43E88 for ; Fri, 22 Nov 2002 07:32:49 -0800 (PST) (envelope-from dwmalone@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 22 Nov 2002 15:32:47 +0000 (GMT) Date: Fri, 22 Nov 2002 15:32:46 +0000 From: David Malone To: Marc Recht Cc: freebsd-current@FreeBSD.ORG Subject: Re: malloc(0) broken? Message-ID: <20021122153246.GA73734@walton.maths.tcd.ie> References: <79620000.1037978720@leeloo.intern.geht.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <79620000.1037978720@leeloo.intern.geht.de> User-Agent: Mutt/1.3.25i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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