From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6glD-0004mL-Q5 for qemu-devel@nongnu.org; Wed, 20 May 2009 04:02:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6gl9-0004jG-1A for qemu-devel@nongnu.org; Wed, 20 May 2009 04:02:47 -0400 Received: from [199.232.76.173] (port=38466 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6gl8-0004jD-P6 for qemu-devel@nongnu.org; Wed, 20 May 2009 04:02:42 -0400 Received: from mx20.gnu.org ([199.232.41.8]:13495) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M6gl8-0004XH-0C for qemu-devel@nongnu.org; Wed, 20 May 2009 04:02:42 -0400 Received: from mx2.redhat.com ([66.187.237.31]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M6gl7-00083D-3n for qemu-devel@nongnu.org; Wed, 20 May 2009 04:02:41 -0400 Message-ID: <4A13B8B9.4000307@redhat.com> Date: Wed, 20 May 2009 10:00:57 +0200 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [PATCH] Make qemu_alloc()/qemu_realloc() return NULL for size==0 (was Re: [Qemu-devel] [PATCH] fix qemu_malloc() error check for size==0) References: <1242678676-19439-1-git-send-email-ehabkost@redhat.com> <20090518221705.GO2079@blackpad> <8763fxvbfk.fsf@pike.pond.sub.org> <20090519140201.GB4254@blackpad> <20090519144424.GD4254@blackpad> <20090519164440.GH4254@blackpad> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: malc Cc: qemu-devel@nongnu.org, Eduardo Habkost , Markus Armbruster malc schrieb: > Thanks for an attempt, but i don't like it either, since it sortof > breaks the (unspoken?) qemu_malloc/realloc contract that those will > never return NULL. I've commited the thing i had in mind. I don't know of such a contract. If you want to have it, you should add a comment which specifies what is guaranteed and what not. And best post the patch to the list first this time. Btw, even with your patch realloc(ptr, 0) with ptr != NULL still can return NULL. And if you now go ahead and forbid size = 0 entirely, I'm almost sure we have a regression as I didn't do the original patch to allow this just for fun but because it's used... Kevin