From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFTc4-0003pH-E1 for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:21:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFTbz-0003oB-SZ for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:21:55 -0500 Received: from [199.232.76.173] (port=36740 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFTbz-0003o7-LG for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:21:51 -0500 Received: from mx20.gnu.org ([199.232.41.8]:50938) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NFTbz-0005mV-Hr for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:21:51 -0500 Received: from mail.codesourcery.com ([38.113.113.100]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFTby-0008Nz-CT for qemu-devel@nongnu.org; Tue, 01 Dec 2009 09:21:50 -0500 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends Date: Tue, 1 Dec 2009 14:21:45 +0000 References: <200912011257.28121.paul@codesourcery.com> <20091201134749.GA23375@mothafucka.localdomain> In-Reply-To: <20091201134749.GA23375@mothafucka.localdomain> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912011421.45396.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Glauber Costa , Markus Armbruster , Gerd Hoffmann On Tuesday 01 December 2009, Glauber Costa wrote: > On Tue, Dec 01, 2009 at 12:57:27PM +0000, Paul Brook wrote: > > > You might want to have a 'static uint8_t zero_length_malloc[0]' and > > > return that instead of the magic cookie '1'. Makes the code more > > > readable IMHO and you'll also have symbol in gdb when debugging qemu. > > > > Having multiple malloc return the same pointer sounds like a really bad > > idea. > > And why's that? > > Keep in mind that *any* dereference over that address is a bug. Dereferencing the address is a bug. However testing the addresses themselves for equality is valid. This is much the same reason I think returning NULL would be a bad idea. Paul