From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 28 21:57:34 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A1D916A858 for ; Wed, 28 Jun 2006 21:57:34 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from hydra.bec.de (www.ostsee-abc.de [62.206.222.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4856843DF5 for ; Wed, 28 Jun 2006 21:56:32 +0000 (GMT) (envelope-from joerg@britannica.bec.de) Received: from britannica.bec.de (unknown [139.30.252.72]) by hydra.bec.de (Postfix) with ESMTP id B278B35707 for ; Wed, 28 Jun 2006 23:56:26 +0200 (CEST) Received: by britannica.bec.de (Postfix, from userid 1000) id 7FF986CB0B; Wed, 28 Jun 2006 23:56:21 +0200 (CEST) Date: Wed, 28 Jun 2006 23:56:21 +0200 From: joerg@britannica.bec.de To: freebsd-hackers@freebsd.org Message-ID: <20060628215621.GC18893@britannica.bec.de> Mail-Followup-To: freebsd-hackers@freebsd.org References: <20060628181045.GA54915@curry.mchp.siemens.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060628181045.GA54915@curry.mchp.siemens.de> User-Agent: Mutt/1.5.11 Subject: Re: Return value of malloc(0) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jun 2006 21:57:34 -0000 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