From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlK0d-0007nE-Vf for qemu-devel@nongnu.org; Mon, 25 Jul 2011 08:11:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlK0d-0005C7-3y for qemu-devel@nongnu.org; Mon, 25 Jul 2011 08:11:43 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:37136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlK0d-0005C3-0F for qemu-devel@nongnu.org; Mon, 25 Jul 2011 08:11:43 -0400 Received: by gxk26 with SMTP id 26so2580461gxk.4 for ; Mon, 25 Jul 2011 05:11:42 -0700 (PDT) Message-ID: <4E2D5D7C.40208@codemonkey.ws> Date: Mon, 25 Jul 2011 07:11:40 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1311583872-362-1-git-send-email-avi@redhat.com> In-Reply-To: <1311583872-362-1-git-send-email-avi@redhat.com> 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: Avi Kivity Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org On 07/25/2011 03:51 AM, Avi Kivity wrote: > qemu_malloc() is type-unsafe as it returns a void pointer. Introduce > QEMU_NEW() (and QEMU_NEWZ()), which return the correct type. Just use g_new() and g_new0() Regards, Anthony Liguori > > Signed-off-by: Avi Kivity > --- > > This is part of my memory API patchset, but doesn't really belong there. > > qemu-common.h | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/qemu-common.h b/qemu-common.h > index ba55719..66effa3 100644 > --- a/qemu-common.h > +++ b/qemu-common.h > @@ -186,6 +186,9 @@ void qemu_free(void *ptr); > char *qemu_strdup(const char *str); > char *qemu_strndup(const char *str, size_t size); > > +#define QEMU_NEW(type) ((type *)(qemu_malloc(sizeof(type)))) > +#define QEMU_NEWZ(type) ((type *)(qemu_mallocz(sizeof(type)))) > + > void qemu_mutex_lock_iothread(void); > void qemu_mutex_unlock_iothread(void); >