summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-11 00:04:50 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-11 00:04:50 +0000
commitdffbc36a6adb56b217a399dd3acfebdd0f1dc5cf (patch)
treec0cde9adc36a47812c71799cf0bd03f0747d4413 /nuttx
parent6157a0e4fd667b835dc74d291019dd61840213cd (diff)
downloadpx4-nuttx-dffbc36a6adb56b217a399dd3acfebdd0f1dc5cf.tar.gz
px4-nuttx-dffbc36a6adb56b217a399dd3acfebdd0f1dc5cf.tar.bz2
px4-nuttx-dffbc36a6adb56b217a399dd3acfebdd0f1dc5cf.zip
Fix a bug introduced in the last check-in
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5728 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/mm/mm_realloc.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/nuttx/mm/mm_realloc.c b/nuttx/mm/mm_realloc.c
index f20bbb255..b738648f2 100644
--- a/nuttx/mm/mm_realloc.c
+++ b/nuttx/mm/mm_realloc.c
@@ -49,6 +49,19 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+/* If multiple heaps are used, then the heap must be passed as a paramter to
+ * mm_malloc() and mm_free(). If the single heap case, mm_malloc() and
+ * mm_free() are not available and we have to use malloc() and free() (which,
+ * internally will use the same heap).
+ */
+
+#ifdef CONFIG_MM_MULTIHEAP
+# define MM_MALLOC(h,s) mm_malloc(h,s)
+# define MM_FREE(h,m) mm_free(h,m)
+#else
+# define MM_MALLOC(h,s) malloc(s)
+# define MM_FREE(h,m) free(m)
+#endif
/****************************************************************************
* Private Functions
@@ -95,14 +108,14 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
if (!oldmem)
{
- return mm_malloc(heap, size);
+ return MM_MALLOC(heap, size);
}
/* If size is zero, then realloc is equivalent to free */
if (size <= 0)
{
- mm_free(heap, oldmem);
+ MM_FREE(heap, oldmem);
return NULL;
}
@@ -348,11 +361,11 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
*/
mm_givesemaphore(heap);
- newmem = (FAR void*)mm_malloc(heap, size);
+ newmem = (FAR void*)MM_MALLOC(heap, size);
if (newmem)
{
memcpy(newmem, oldmem, oldsize);
- mm_free(heap, oldmem);
+ MM_FREE(heap, oldmem);
}
return newmem;