From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] Introduce QEMU_NEW() Date: Mon, 25 Jul 2011 07:11:40 -0500 Message-ID: <4E2D5D7C.40208@codemonkey.ws> References: <1311583872-362-1-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org To: Avi Kivity Return-path: In-Reply-To: <1311583872-362-1-git-send-email-avi@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: 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); >