From c488f6e3359155770df4e7edae05a98babaec710 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Mon, 1 Jun 2020 20:44:34 -0700 Subject: [PATCH] use calloc instead of malloc;memset in zmalloc() This is more efficient for larger allocations, where the allocator can just provide a zeroed page from the operating system. --- lib/common/memory.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/common/memory.c b/lib/common/memory.c index 5610a450e..53bb083af 100644 --- a/lib/common/memory.c +++ b/lib/common/memory.c @@ -20,12 +20,9 @@ void *zmalloc(size_t nbytes) { - char *rv; if (nbytes == 0) return 0; - rv = gmalloc(nbytes); - memset(rv, 0, nbytes); - return rv; + return gcalloc(1, nbytes); } void *zrealloc(void *ptr, size_t size, size_t elt, size_t osize) -- 2.40.0