From owner-freebsd-current Sat Nov 23 2:41:41 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 808B737B401 for ; Sat, 23 Nov 2002 02:41:40 -0800 (PST) Received: from HAL9000.homeunix.com (12-232-220-15.client.attbi.com [12.232.220.15]) by mx1.FreeBSD.org (Postfix) with ESMTP id B7AE643EAA for ; Sat, 23 Nov 2002 02:41:39 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.6/8.12.5) with ESMTP id gANAfZm9013727; Sat, 23 Nov 2002 02:41:35 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id gANAfZwu013726; Sat, 23 Nov 2002 02:41:35 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Date: Sat, 23 Nov 2002 02:41:35 -0800 From: David Schultz To: Bruce Evans Cc: "M. Warner Losh" , marc@informatik.uni-bremen.de, freebsd-current@FreeBSD.ORG Subject: Re: malloc(0) broken? Message-ID: <20021123104135.GA13619@HAL9000.homeunix.com> Mail-Followup-To: Bruce Evans , "M. Warner Losh" , marc@informatik.uni-bremen.de, freebsd-current@FreeBSD.ORG References: <20021122.193635.99607054.imp@bsdimp.com> <20021123195334.W48944-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021123195334.W48944-100000@gamplex.bde.org> 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 Thus spake Bruce Evans : > Er, malloc(0) is defined as returning either a null pointer or a pointer > to 0 bytes of allocated space. Which one it chooses to return is > implementation-defined, not undefined. C90 has a bogus requirement that > the pointer for malloc(0) be "unique", whatever that means. C99 only > requires that the objects pointed to by the results of malloc() be > disjoint, and this is satisfied by FreeBSD's behaviour of returning the > same magic pointer for each instance of malloc(0). In FreeBSD, malloc(0) returns a distinct pointer each time by making a 16-byte allocation. I seem to recall that it may have returned a single magic pointer at one time, so what you say might have been correct some time ago. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message