mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 03:05:40 +08:00
mm: support mm_initialize_heap to specify a specific heap pointer
Support user pass it own heap struct to the mm_initialize_heap() to avoid the heap struct is reserved from the heap range Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
@@ -198,31 +198,44 @@ static void mm_delayfree(struct mm_heap_s *heap, void *mem, bool delay)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mm_initialize
|
||||
* Name: mm_initialize_heap
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected heap data structures, providing the initial
|
||||
* heap region.
|
||||
*
|
||||
* Input Parameters:
|
||||
* heap - The selected heap
|
||||
* heap - If heap is NULL, will use heapstart initialize heap context,
|
||||
* otherwise, will use heap alloc a heap context, caller need
|
||||
* free it after mm_uninitialize.
|
||||
* name - The heap procfs name
|
||||
* heapstart - Start of the initial heap region
|
||||
* heapsize - Size of the initial heap region
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
* Return the address of a new heap instance.
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct mm_heap_s *mm_initialize(const char *name,
|
||||
void *heap_start, size_t heap_size)
|
||||
struct mm_heap_s *
|
||||
mm_initialize_heap(struct mm_heap_s *heap, const char *name,
|
||||
void *heapstart, size_t heapsize)
|
||||
{
|
||||
struct mm_heap_s *heap;
|
||||
if (heap == NULL)
|
||||
{
|
||||
heap = host_memalign(sizeof(void *), sizeof(*heap));
|
||||
}
|
||||
else
|
||||
{
|
||||
heap = mm_memalign(heap, MM_ALIGN, sizeof(struct mm_heap_s));
|
||||
}
|
||||
|
||||
heap = host_memalign(sizeof(void *), sizeof(*heap));
|
||||
DEBUGASSERT(heap);
|
||||
if (heap == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(heap, 0, sizeof(struct mm_heap_s));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user