diff options
author | Richard Henderson <rth@twiddle.net> | 2010-05-21 10:37:51 -0700 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2010-05-28 23:27:19 +0200 |
commit | 50401022d8fbdcdaf84d28e7b813ee94c2d47325 (patch) | |
tree | 1d763f1b80af98c25bbba84fa6986a22b421642a /qemu-malloc.c | |
parent | 564e2fe8cd63ca6d5413408a1a4f9ee9cf471fff (diff) | |
download | qemu-50401022d8fbdcdaf84d28e7b813ee94c2d47325.tar.gz qemu-50401022d8fbdcdaf84d28e7b813ee94c2d47325.tar.bz2 qemu-50401022d8fbdcdaf84d28e7b813ee94c2d47325.zip |
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 <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'qemu-malloc.c')
-rw-r--r-- | qemu-malloc.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/qemu-malloc.c b/qemu-malloc.c index 6cdc5deb78..1b33e04601 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) |