|
From: | Anthony Liguori |
Subject: | Re: [Qemu-devel] [PATCH] Introduce QEMU_NEW() |
Date: | Mon, 25 Jul 2011 07:19:29 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |