提交 50401022 编写于 作者: R Richard Henderson 提交者: Aurelien Jarno

Use calloc in qemu_mallocz.

Avoids the memset if the allocator has gotten new zeroed
storage from the operating system.
Signed-off-by: NRichard Henderson <rth@twiddle.net>
Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
上级 564e2fe8
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册