summaryrefslogtreecommitdiff
path: root/src/lib/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/malloc.c')
-rw-r--r--src/lib/malloc.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/malloc.c b/src/lib/malloc.c
index cd86f99f0b..7d787d631e 100644
--- a/src/lib/malloc.c
+++ b/src/lib/malloc.c
@@ -1,5 +1,6 @@
-#include <stdlib.h>
#include <console/console.h>
+#include <stdlib.h>
+#include <string.h>
#if CONFIG(DEBUG_MALLOC)
#define MALLOCDBG(x...) printk(BIOS_SPEW, x)
@@ -54,6 +55,15 @@ void *malloc(size_t size)
return memalign(sizeof(u64), size);
}
+void *calloc(size_t nitems, size_t size)
+{
+ void *p = malloc(nitems * size);
+ if (p)
+ memset(p, 0, nitems * size);
+
+ return p;
+}
+
void free(void *ptr)
{
if (ptr == NULL)