From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW() Date: Mon, 25 Jul 2011 07:19:29 -0500 Message-ID: <4E2D5F51.9030608@codemonkey.ws> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Markus Armbruster , Peter Maydell , Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org To: Alexander Graf Return-path: Received: from mail-gy0-f174.google.com ([209.85.160.174]:33267 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750864Ab1GYMTd (ORCPT ); Mon, 25 Jul 2011 08:19:33 -0400 Received: by gyh3 with SMTP id 3so2159940gyh.19 for ; Mon, 25 Jul 2011 05:19:32 -0700 (PDT) In-Reply-To: <4870326D-E442-4F1E-85B6-951BFE1C9459@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: 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 > >