From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHFxr-0001ti-Do for qemu-devel@nongnu.org; Sun, 06 Dec 2009 07:11:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHFxo-0001t2-E5 for qemu-devel@nongnu.org; Sun, 06 Dec 2009 07:11:45 -0500 Received: from [199.232.76.173] (port=53173 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHFxn-0001sm-M8 for qemu-devel@nongnu.org; Sun, 06 Dec 2009 07:11:43 -0500 Received: from fe02x03-cgp.akado.ru ([77.232.31.165]:64466 helo=akado.ru) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHFxn-0005xu-9D for qemu-devel@nongnu.org; Sun, 06 Dec 2009 07:11:43 -0500 Date: Sun, 6 Dec 2009 15:11:40 +0300 (MSK) From: malc Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends In-Reply-To: <4B1B9E6A.2000904@redhat.com> Message-ID: References: <4B193DA5.6040507@codemonkey.ws> <4B1B8A08.3060704@redhat.com> <4B1B9E6A.2000904@redhat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Paul Brook , Markus Armbruster , qemu-devel@nongnu.org On Sun, 6 Dec 2009, Avi Kivity wrote: > On 12/06/2009 01:53 PM, malc wrote: > > On Sun, 6 Dec 2009, Avi Kivity wrote: > > > > > > > On 12/06/2009 12:22 PM, malc wrote: > > > > > > > Here, i believe, you are inventing artificial restrictions on how > > > > malloc behaves, i don't see anything that prevents the implementor > > > > from setting aside a range of addresses with 31st bit set as an > > > > indicator of "zero" allocations, and then happily giving it to the > > > > user of malloc and consumming it in free. > > > > > > > > > > > The implementation needs to track which addresses it handed out, since it > > > is > > > required that malloc(0) != malloc(0) (unless both are NULL). > > > > > You haven't read carefully, i said range. > > > > I did in fact. Consider a loop > > malloc(0); > p = malloc(0); > while (1) { > n = malloc(0); > free(p); > p = n; > } > > without some form of tracking, you won't be able to return unique addresses > eventually. So? There will be tracking, it's the same as with OpenBSD where allocations of zero and greater than zero are handled differently. -- mailto:av1474@comtv.ru