From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFU1V-000812-6N for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:48:13 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFU1Q-0007z5-H7 for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:48:12 -0500 Received: from [199.232.76.173] (port=59801 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFU1Q-0007z0-Cn for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:48:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31852) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFU1Q-0000cL-1y for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:48:08 -0500 Message-ID: <4B152C9C.1000202@redhat.com> Date: Tue, 01 Dec 2009 15:47:56 +0100 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends References: <4B150EAD.4050502@redhat.com> <200912011257.28121.paul@codesourcery.com> <20091201134749.GA23375@mothafucka.localdomain> 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: Markus Armbruster Cc: Glauber Costa , Paul Brook , qemu-devel@nongnu.org On 12/01/09 15:08, Markus Armbruster wrote: > For what it's worth, it violates the spec for malloc(). For zero-sized > allocations, we may either return a null pointer (but we already decided > we don't want to), or an object different from any other object alive. Which clearly rules out the fixed memory location for malloc(0). "malloc(size ? size : 1)" is indeed the easiest way to make sure we conform to the spec and also don't return NULL. cheers, Gerd