From d2957917dc9e0768fbf6188e2736de6bbb4520e5 Mon Sep 17 00:00:00 2001 From: Felipe Martinez Date: Sat, 30 Nov 2024 18:03:54 +0000 Subject: [PATCH] Implement calloc --- src/stdlib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/stdlib.c b/src/stdlib.c index 005b01807c..41f47514bb 100644 --- a/src/stdlib.c +++ b/src/stdlib.c @@ -28,10 +28,11 @@ void __wrap_free(void* ptr) { } void* calloc(size_t num, size_t size) { - (void) num; - (void) size; - // Not supported - return NULL; + void *ptr = malloc(num * size); + if (ptr) { + memset(ptr, 0, num * size); + } + return ptr; } void* __wrap_calloc(size_t num, size_t size) {