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>
This commit is contained in:
parent
564e2fe8cd
commit
50401022d8
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user