From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHFts-0000zA-Fm for qemu-devel@nongnu.org; Sun, 06 Dec 2009 07:07:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHFtl-0000xx-7f for qemu-devel@nongnu.org; Sun, 06 Dec 2009 07:07:37 -0500 Received: from [199.232.76.173] (port=53450 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHFtj-0000xl-BS for qemu-devel@nongnu.org; Sun, 06 Dec 2009 07:07:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15081) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHFti-0005Ze-Q1 for qemu-devel@nongnu.org; Sun, 06 Dec 2009 07:07:31 -0500 Message-ID: <4B1B9E6A.2000904@redhat.com> Date: Sun, 06 Dec 2009 14:07:06 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends References: <4B193DA5.6040507@codemonkey.ws> <4B1B8A08.3060704@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: malc Cc: Paul Brook , Markus Armbruster , qemu-devel@nongnu.org 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. -- error compiling committee.c: too many arguments to function