diff options
Diffstat (limited to 'nuttx/mm/umm_zalloc.c')
-rw-r--r-- | nuttx/mm/umm_zalloc.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/nuttx/mm/umm_zalloc.c b/nuttx/mm/umm_zalloc.c index 835841a75..0c2ddddeb 100644 --- a/nuttx/mm/umm_zalloc.c +++ b/nuttx/mm/umm_zalloc.c @@ -44,12 +44,27 @@ #include <nuttx/mm.h> -#ifdef CONFIG_MM_USER_HEAP - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) +/* In the kernel build, there a multiple user heaps; one for each task + * group. In this build configuration, the user heap structure lies + * in a reserved region at the beginning of the .bss/.data address + * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by + * ARCH_DATA_RESERVE + */ + +# include <nuttx/addrenv.h> +# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE) + +#else +/* Otherwise, the user heap data structures are in common .bss */ + +# define USR_HEAP &g_mmheap; +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -84,8 +99,6 @@ FAR void *zalloc(size_t size) #else /* Use mm_zalloc() becuase it implements the clear */ - return mm_zalloc(&g_mmheap, size); + return mm_zalloc(USR_HEAP, size); #endif } - -#endif /* CONFIG_MM_USER_HEAP */ |