From f956fed4d181d41a5b1c49bba9dce46d8197d428 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Tue, 11 Jun 2024 17:48:41 +0000 Subject: [PATCH] Reapply "smalloc: smalloc() already clears memory, scalloc() need not do it again" This reverts commit eb7fe4550ff2a569d0d8c71de16a1ea1e1aaf0a5. It turns out that each buffer is in fact cleared in smalloc_pool() when it is called by smalloc(). So there is no need to clear the buffer a second time in scalloc. Signed-off-by: Vincent Fu --- smalloc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/smalloc.c b/smalloc.c index 134f3d77..23243054 100644 --- a/smalloc.c +++ b/smalloc.c @@ -566,13 +566,7 @@ void *smalloc(size_t size) void *scalloc(size_t nmemb, size_t size) { - void *ret; - - ret = smalloc(nmemb * size); - if (ret) - memset(ret, 0, nmemb * size); - - return ret; + return smalloc(nmemb * size); } char *smalloc_strdup(const char *str) -- 2.25.1