summaryrefslogtreecommitdiffstats
path: root/src/lib/stdlib.C
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/stdlib.C')
-rw-r--r--src/lib/stdlib.C15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/stdlib.C b/src/lib/stdlib.C
index d9fa9e9fc..f0c3fad74 100644
--- a/src/lib/stdlib.C
+++ b/src/lib/stdlib.C
@@ -77,3 +77,18 @@ void* realloc(void* p, size_t s)
return HeapManager::realloc(p,s);
}
+void* calloc(size_t num, size_t size)
+{
+ // Allocate a block of memory for an array of 'num' elements, each of them
+ // 'size' bytes long and initialize to zero
+ size_t total_size = num * size;
+ void* mem = NULL;
+
+ if (total_size)
+ {
+ mem = malloc(total_size);
+ memset(mem, 0, total_size);
+ }
+
+ return mem;
+}
OpenPOWER on IntegriCloud