From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGy6t-00034b-9q for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:07:55 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGy6o-00031T-CF for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:07:54 -0500 Received: from [199.232.76.173] (port=40632 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGy6o-00031P-5p for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:07:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20131) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NGy6n-0006zA-TM for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:07:50 -0500 Message-ID: <4B1A9359.8080305@redhat.com> Date: Sat, 05 Dec 2009 19:07:37 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends References: <4B193DA5.6040507@codemonkey.ws> In-Reply-To: <4B193DA5.6040507@codemonkey.ws> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Paul Brook , Markus Armbruster , qemu-devel@nongnu.org On 12/04/2009 06:49 PM, Anthony Liguori wrote: > > I still believe that it is poor practice to pass size==0 to > *malloc(). I think actively discouraging this in qemu is a good thing > because it's a broken idiom. Why? Unless we have a separate array allocator (like C++'s new and new[]), we need to support zero-element arrays without pushing the burden to callers (in the same way that for () supports zero iteration loops without a separate if ()). -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.