summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile4
-rw-r--r--common/calloc.c19
-rw-r--r--common/dummy_malloc.c13
-rw-r--r--common/tlsf_malloc.c16
4 files changed, 21 insertions, 31 deletions
diff --git a/common/Makefile b/common/Makefile
index 13920cc5a6..861365bd55 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -34,8 +34,8 @@ obj-$(CONFIG_GLOBALVAR) += globalvar.o
obj-$(CONFIG_GREGORIAN_CALENDER) += date.o
obj-$(CONFIG_KALLSYMS) += kallsyms.o
obj-$(CONFIG_MALLOC_DLMALLOC) += dlmalloc.o
-obj-$(CONFIG_MALLOC_TLSF) += tlsf_malloc.o tlsf.o
-obj-$(CONFIG_MALLOC_DUMMY) += dummy_malloc.o
+obj-$(CONFIG_MALLOC_TLSF) += tlsf_malloc.o tlsf.o calloc.o
+obj-$(CONFIG_MALLOC_DUMMY) += dummy_malloc.o calloc.o
obj-$(CONFIG_MEMINFO) += meminfo.o
obj-$(CONFIG_MENU) += menu.o
obj-$(CONFIG_MODULES) += module.o
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);
diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c
index 641baa125a..fa4f5d126c 100644
--- a/common/dummy_malloc.c
+++ b/common/dummy_malloc.c
@@ -50,16 +50,3 @@ void *realloc(void *ptr, size_t size)
{
BUG();
}
-
-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;
-}
diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c
index a3541d8256..aa3ab23975 100644
--- a/common/tlsf_malloc.c
+++ b/common/tlsf_malloc.c
@@ -39,22 +39,6 @@ void *malloc(size_t bytes)
}
EXPORT_SYMBOL(malloc);
-/*
- * calloc calls malloc, then zeroes out the allocated chunk.
- */
-void *calloc(size_t n, size_t elem_size)
-{
- void *mem;
- size_t sz;
-
- sz = n * elem_size;
- mem = malloc(sz);
- memset(mem, 0, sz);
-
- return mem;
-}
-EXPORT_SYMBOL(calloc);
-
void free(void *mem)
{
tlsf_free(tlsf_mem_pool, mem);