From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHgNe-0004GT-0m for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:24:10 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHgNZ-0004Bo-4T for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:24:09 -0500 Received: from [199.232.76.173] (port=41376 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHgNY-0004BZ-9Z for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:24:04 -0500 Received: from mx20.gnu.org ([199.232.41.8]:45927) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NHgNY-0007Yf-LR for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:24:04 -0500 Received: from mail.codesourcery.com ([38.113.113.100]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHgNX-0008RQ-3F for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:24:03 -0500 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends Date: Mon, 7 Dec 2009 16:24:00 +0000 References: <4B1D2462.3070000@codemonkey.ws> In-Reply-To: <4B1D2462.3070000@codemonkey.ws> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912071624.00559.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Kevin Wolf , Avi Kivity , Markus Armbruster , qemu-devel@nongnu.org > type *qemu_new(type, n_types); > type *qemu_new0(type, n_types); > > type *qemu_renew(type, mem, n_types); > type *qemu_renew0(type, mem, n_types); It always annoys me having to specify element count for things that aren't arrays. I suggestion a single object allocation function, and an array allocation function that allows zero length arrays. Possibly also a must-not-be-zero array form if we think it's important. Note that conversion to object/type based allocation is not always straightforward because inheritance means we don't have the final object type when doing the allocation. Paul