mm: add mm_largest api to get the current largest available memory block

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2024-06-30 16:10:22 +08:00 committed by Xiang Xiao
parent 2cdfda149a
commit 84333881d7
4 changed files with 52 additions and 0 deletions

View File

@ -623,6 +623,20 @@ size_t mm_heapfree(struct mm_heap_s *heap)
{
return SIZE_MAX;
}
/****************************************************************************
* Name: mm_heapfree_largest
*
* Description:
* Return the largest chunk of contiguous memory in the heap
*
****************************************************************************/
size_t mm_heapfree_largest(FAR struct mm_heap_s *heap)
{
return SIZE_MAX;
}
#else /* CONFIG_MM_CUSTOMIZE_MANAGER */
void up_allocate_heap(void **heap_start, size_t *heap_size)

View File

@ -390,6 +390,7 @@ struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap,
FAR const struct malltask *task);
size_t mm_heapfree(FAR struct mm_heap_s *heap);
size_t mm_heapfree_largest(FAR struct mm_heap_s *heap);
/* Functions contained in kmm_mallinfo.c ************************************/

View File

@ -200,3 +200,27 @@ size_t mm_heapfree(FAR struct mm_heap_s *heap)
{
return heap->mm_heapsize - heap->mm_curused;
}
/****************************************************************************
* Name: mm_heapfree_largest
*
* Description:
* Return the largest chunk of contiguous memory in the heap
*
****************************************************************************/
size_t mm_heapfree_largest(FAR struct mm_heap_s *heap)
{
FAR struct mm_freenode_s *node;
for (node = heap->mm_nodelist[MM_NNODES - 1].blink; node;
node = node->blink)
{
size_t nodesize = MM_SIZEOF_NODE(node);
if (nodesize != 0)
{
return nodesize;
}
}
return 0;
}

View File

@ -1476,3 +1476,16 @@ size_t mm_heapfree(FAR struct mm_heap_s *heap)
{
return heap->mm_heapsize - heap->mm_curused;
}
/****************************************************************************
* Name: mm_heapfree_largest
*
* Description:
* Return the largest chunk of contiguous memory in the heap
*
****************************************************************************/
size_t mm_heapfree_largest(FAR struct mm_heap_s *heap)
{
return SIZE_MAX;
}