From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHgQb-0005pv-QJ for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:27:14 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHgQV-0005n5-Fm for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:27:11 -0500 Received: from [199.232.76.173] (port=41417 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHgQU-0005mt-8H for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:27:06 -0500 Received: from mail-qy0-f194.google.com ([209.85.221.194]:58934) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHgQU-0007mT-K7 for qemu-devel@nongnu.org; Mon, 07 Dec 2009 11:27:06 -0500 Received: by qyk32 with SMTP id 32so1902087qyk.4 for ; Mon, 07 Dec 2009 08:27:05 -0800 (PST) Message-ID: <4B1D2CD5.5030608@codemonkey.ws> Date: Mon, 07 Dec 2009 10:27:01 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends References: <4B1D2462.3070000@codemonkey.ws> <200912071624.00559.paul@codesourcery.com> In-Reply-To: <200912071624.00559.paul@codesourcery.com> 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: Paul Brook Cc: Kevin Wolf , Avi Kivity , Markus Armbruster , qemu-devel@nongnu.org Paul Brook wrote: >> 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. > Sure. > 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. > That's if you have the base object do the allocation, yup. > Paul >