summaryrefslogtreecommitdiffstats
path: root/common/calloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/calloc.c')
-rw-r--r--common/calloc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/calloc.c b/common/calloc.c
new file mode 100644
index 0000000000..2b933ec272
--- /dev/null
+++ b/common/calloc.c
@@ -0,0 +1,19 @@
+#include <common.h>
+#include <malloc.h>
+
+/*
+ * calloc calls malloc, then zeroes out the allocated chunk.
+ */
+void *calloc(size_t n, size_t elem_size)
+{
+ size_t size = elem_size * n;
+ void *r = malloc(size);
+
+ if (!r)
+ return r;
+
+ memset(r, 0x0, size);
+
+ return r;
+}
+EXPORT_SYMBOL(calloc);