From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:37303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlK8F-00035k-13 for qemu-devel@nongnu.org; Mon, 25 Jul 2011 08:19:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlK8D-0006i5-NE for qemu-devel@nongnu.org; Mon, 25 Jul 2011 08:19:34 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:56745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlK8D-0006hu-Ea for qemu-devel@nongnu.org; Mon, 25 Jul 2011 08:19:33 -0400 Received: by gyg8 with SMTP id 8so428881gyg.4 for ; Mon, 25 Jul 2011 05:19:32 -0700 (PDT) Message-ID: <4E2D5F51.9030608@codemonkey.ws> Date: Mon, 25 Jul 2011 07:19:29 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1311583872-362-1-git-send-email-avi@redhat.com> <4E2D3CC2.7000206@redhat.com> <0AF62DBC-C10D-4C06-9FE3-CCE8AF912462@suse.de> <4E2D3F3E.70303@redhat.com> <060B54D0-566A-4749-BD7C-B3035C7E1792@suse.de> <4E2D40F0.1070604@redhat.com> <4870326D-E442-4F1E-85B6-951BFE1C9459@suse.de> In-Reply-To: <4870326D-E442-4F1E-85B6-951BFE1C9459@suse.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: qemu-devel@nongnu.org, Peter Maydell , Markus Armbruster , kvm@vger.kernel.org, Avi Kivity On 07/25/2011 06:11 AM, Alexander Graf wrote: > > #define QEMU_NEW_MULTI(type, len) ((type *)(qemu_mallocz(sizeof(type) * len))) > > char *arr = QEMU_NEW_MULTI(char, 1024); > >> Still not covered: allocating a struct with a variable-size array as >> final member. I guess a solution for that can be found if we care >> enough. > > Yeah, but at the end of the day I'd assume most of us know C and can just open code this all, no? While it's always fun to reinvent things, glib has already solved all of this and we're already dependent on it in the build: http://developer.gnome.org/glib/stable/glib-Memory-Allocation.html It also has fancy ways to hook memory allocation for debugging. Regards, Anthony Liguori > > Alex > >