diff options
Diffstat (limited to 'qemu-malloc.c')
-rw-r--r-- | qemu-malloc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/qemu-malloc.c b/qemu-malloc.c index 36b0b3641e..ecffb676e2 100644 --- a/qemu-malloc.c +++ b/qemu-malloc.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" +#include "trace.h" #include <stdlib.h> static void *oom_check(void *ptr) @@ -34,6 +35,7 @@ static void *oom_check(void *ptr) void qemu_free(void *ptr) { + trace_qemu_free(ptr); free(ptr); } @@ -48,18 +50,24 @@ static int allow_zero_malloc(void) void *qemu_malloc(size_t size) { + void *ptr; if (!size && !allow_zero_malloc()) { abort(); } - return oom_check(malloc(size ? size : 1)); + ptr = oom_check(malloc(size ? size : 1)); + trace_qemu_malloc(size, ptr); + return ptr; } void *qemu_realloc(void *ptr, size_t size) { + void *newptr; if (!size && !allow_zero_malloc()) { abort(); } - return oom_check(realloc(ptr, size ? size : 1)); + newptr = oom_check(realloc(ptr, size ? size : 1)); + trace_qemu_realloc(ptr, size, newptr); + return newptr; } void *qemu_mallocz(size_t size) |