summaryrefslogtreecommitdiff
path: root/nuttx/mm/mm_calloc.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-08 20:36:18 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-08 20:36:18 +0000
commit5e160bcf59441ce40088ca089cbeb4461a0b0d6a (patch)
treea71405922d088fd3dd1cd878ffb53e90bfe6a42e /nuttx/mm/mm_calloc.c
parent6137a8aa8f69cb0c197efced18d7e49144791666 (diff)
downloadpx4-nuttx-5e160bcf59441ce40088ca089cbeb4461a0b0d6a.tar.gz
px4-nuttx-5e160bcf59441ce40088ca089cbeb4461a0b0d6a.tar.bz2
px4-nuttx-5e160bcf59441ce40088ca089cbeb4461a0b0d6a.zip
Add support for multiple heaps
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5720 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/mm/mm_calloc.c')
-rw-r--r--nuttx/mm/mm_calloc.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/nuttx/mm/mm_calloc.c b/nuttx/mm/mm_calloc.c
index 576081a16..0a433947d 100644
--- a/nuttx/mm/mm_calloc.c
+++ b/nuttx/mm/mm_calloc.c
@@ -37,8 +37,11 @@
* Included Files
****************************************************************************/
-#include "mm_environment.h"
-#include "mm_internal.h"
+#include <nuttx/config.h>
+
+#include <stdlib.h>
+
+#include <nuttx/mm.h>
/****************************************************************************
* Pre-processor Definitions
@@ -49,6 +52,28 @@
****************************************************************************/
/****************************************************************************
+ * Name: mm_calloc
+ *
+ * Descripton:
+ * calloc calculates the size of the allocation and calls zalloc
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_MM_MULTIHEAP
+FAR void *mm_calloc(FAR struct mm_heap_s *heap, size_t n, size_t elem_size)
+{
+ FAR void *ret = NULL;
+
+ if (n > 0 && elem_size > 0)
+ {
+ ret = mm_zalloc(heap, n * elem_size);
+ }
+
+ return ret;
+}
+#endif
+
+/****************************************************************************
* Name: calloc
*
* Descripton:
@@ -56,8 +81,12 @@
*
****************************************************************************/
+#if !defined(CONFIG_NUTTX_KERNEL) || !defined(__KERNEL__)
FAR void *calloc(size_t n, size_t elem_size)
{
+#ifdef CONFIG_MM_MULTIHEAP
+ return mm_calloc(&g_mmheap, n, elem_size);
+#else
FAR void *ret = NULL;
if (n > 0 && elem_size > 0)
@@ -66,4 +95,6 @@ FAR void *calloc(size_t n, size_t elem_size)
}
return ret;
+#endif
}
+#endif