From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qu6he-0006MO-8Y for qemu-devel@nongnu.org; Thu, 18 Aug 2011 13:48:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qu6hd-00022d-3A for qemu-devel@nongnu.org; Thu, 18 Aug 2011 13:48:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qu6hc-00022Y-R0 for qemu-devel@nongnu.org; Thu, 18 Aug 2011 13:48:25 -0400 From: Avi Kivity Date: Thu, 18 Aug 2011 10:48:17 -0700 Message-Id: <1313689697-23627-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH] Wire g_new() and friends to the qemu_malloc() family List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori , Blue Swirl Cc: qemu-devel@nongnu.org This makes the tracing infrastructure available to users of g_new(). Signed-off-by: Avi Kivity --- qemu-common.h | 1 + qemu-malloc.c | 15 +++++++++++++++ vl.c | 1 + 3 files changed, 17 insertions(+), 0 deletions(-) diff --git a/qemu-common.h b/qemu-common.h index 74d5c4b..fbe2de0 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -180,6 +180,7 @@ const char *path(const char *pathname); #define qemu_isascii(c) isascii((unsigned char)(c)) #define qemu_toascii(c) toascii((unsigned char)(c)) +void qemu_malloc_init(void); void *qemu_oom_check(void *ptr); void *qemu_malloc(size_t size); void *qemu_realloc(void *ptr, size_t size); diff --git a/qemu-malloc.c b/qemu-malloc.c index b9b3851..8b0c1ec 100644 --- a/qemu-malloc.c +++ b/qemu-malloc.c @@ -24,6 +24,21 @@ #include "qemu-common.h" #include "trace.h" #include +#include + +static GMemVTable gmemvtable = { + .malloc = qemu_malloc, + .realloc = qemu_realloc, + .free = qemu_free, +}; + +/** + * qemu_malloc_init: initialize memory management + */ +void qemu_malloc_init(void) +{ + g_mem_set_vtable(&gmemvtable); +} void qemu_free(void *ptr) { diff --git a/vl.c b/vl.c index c714127..7c4f8da 100644 --- a/vl.c +++ b/vl.c @@ -2106,6 +2106,7 @@ int main(int argc, char **argv, char **envp) atexit(qemu_run_exit_notifiers); error_set_progname(argv[0]); + qemu_malloc_init(); init_clocks(); -- 1.7.6