mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 19:54:32 +02:00
Add api to get total heap size in bytes for given capability
This commit is contained in:
@@ -329,6 +329,18 @@ IRAM_ATTR void *heap_caps_calloc( size_t n, size_t size, uint32_t caps)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t heap_caps_get_total_size(uint32_t caps)
|
||||||
|
{
|
||||||
|
size_t total_size = 0;
|
||||||
|
heap_t *heap;
|
||||||
|
SLIST_FOREACH(heap, ®istered_heaps, next) {
|
||||||
|
if (heap_caps_match(heap, caps)) {
|
||||||
|
total_size += (heap->end - heap->start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total_size;
|
||||||
|
}
|
||||||
|
|
||||||
size_t heap_caps_get_free_size( uint32_t caps )
|
size_t heap_caps_get_free_size( uint32_t caps )
|
||||||
{
|
{
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
|
@@ -101,6 +101,20 @@ void *heap_caps_realloc( void *ptr, size_t size, int caps);
|
|||||||
*/
|
*/
|
||||||
void *heap_caps_calloc(size_t n, size_t size, uint32_t caps);
|
void *heap_caps_calloc(size_t n, size_t size, uint32_t caps);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the total size of all the regions that have the given capabilities
|
||||||
|
*
|
||||||
|
* This function takes all regions capable of having the given capabilities allocated in them
|
||||||
|
* and adds up the total space they have.
|
||||||
|
*
|
||||||
|
* @param caps Bitwise OR of MALLOC_CAP_* flags indicating the type
|
||||||
|
* of memory
|
||||||
|
*
|
||||||
|
* @return total size in bytes
|
||||||
|
*/
|
||||||
|
|
||||||
|
size_t heap_caps_get_total_size(uint32_t caps);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the total free size of all the regions that have the given capabilities
|
* @brief Get the total free size of all the regions that have the given capabilities
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user