From: Richard Henderson Date: Fri, 21 May 2010 17:37:51 +0000 (-0700) Subject: Use calloc in qemu_mallocz. X-Git-Tag: v0.13.0-rc0~419 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50401022d8fbdcdaf84d28e7b813ee94c2d47325;p=thirdparty%2Fqemu.git 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 --- diff --git a/qemu-malloc.c b/qemu-malloc.c index 6cdc5deb788..1b33e04601a 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)