From 50401022d8fbdcdaf84d28e7b813ee94c2d47325 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 21 May 2010 10:37:51 -0700 Subject: Use calloc in qemu_mallocz. Avoids the memset if the allocator has gotten new zeroed storage from the operating system. Signed-off-by: Richard Henderson Signed-off-by: Aurelien Jarno --- qemu-malloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'qemu-malloc.c') diff --git a/qemu-malloc.c b/qemu-malloc.c index 6cdc5de..1b33e04 100644 --- a/qemu-malloc.c +++ b/qemu-malloc.c @@ -69,10 +69,10 @@ void *qemu_realloc(void *ptr, size_t size) void *qemu_mallocz(size_t size) { - void *ptr; - ptr = qemu_malloc(size); - memset(ptr, 0, size); - return ptr; + if (!size && !allow_zero_malloc()) { + abort(); + } + return oom_check(calloc(1, size ? size : 1)); } char *qemu_strdup(const char *str) -- cgit v1.1