Reapply "smalloc: smalloc() already clears memory, scalloc() need not do it again"
authorVincent Fu <vincent.fu@samsung.com>
Tue, 11 Jun 2024 17:48:41 +0000 (17:48 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Tue, 11 Jun 2024 17:51:57 +0000 (17:51 +0000)
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 <vincent.fu@samsung.com>
smalloc.c

index 134f3d775e48893ff666d6fefb0a9d238f6db9ad..23243054ec7ab401ee7d89d73db81d3d809dd612 100644 (file)
--- 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)