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>
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)