src/allocator.c

changeset 1330
33c95cfc088e
parent 1318
12fa1d37fe48
--- a/src/allocator.c	Fri May 23 14:00:24 2025 +0200
+++ b/src/allocator.c	Sat May 24 00:04:11 2025 +0200
@@ -29,6 +29,7 @@
 #include "cx/allocator.h"
 
 #include <errno.h>
+#include <string.h>
 
 static void *cx_malloc_stdlib(
         cx_attr_unused void *d,
@@ -116,6 +117,17 @@
     return allocator->cl->malloc(allocator->data, n);
 }
 
+void *cxZalloc(
+        const CxAllocator *allocator,
+        size_t n
+) {
+    void *mem = allocator->cl->malloc(allocator->data, n);
+    if (mem != NULL) {
+        memset(mem, 0, n);
+    }
+    return mem;
+}
+
 void *cxRealloc(
         const CxAllocator *allocator,
         void *mem,

mercurial