From dffbc36a6adb56b217a399dd3acfebdd0f1dc5cf Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 11 Mar 2013 00:04:50 +0000 Subject: 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 --- nuttx/mm/mm_realloc.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'nuttx') 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; -- cgit v1.2.3