Chapter 2. API Reference
void heap_caps_get_info(multi_heap_info_t *info, uint32_t caps)
Get heap info for all regions with the given capabilities.
Calls multi_heap_info() on all heaps which share the given capabilities. The information returned is an aggre-
gate across all matching heaps. The meanings of fields are the same as defined for multi_heap_info_t, except
that minimum_free_bytes has the same caveats described in heap_caps_get_minimum_free_size().
Parameters
• info: Pointer to a structure which will be filled with relevant heap metadata.
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory
void heap_caps_print_heap_info(uint32_t caps)
Print a summary of all memory with the given capabilities.
Calls multi_heap_info on all heaps which share the given capabilities, and prints a two-line summary for each,
then a total summary.
Parameters
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory
bool heap_caps_check_integrity_all(bool print_errors)
Check integrity of all heap memory in the system.
Calls multi_heap_check on all heaps. Optionally print errors if heaps are corrupt.
Calling this function is equivalent to calling heap_caps_check_integrity with the caps argument set to MAL-
LOC_CAP_INVALID.
Return True if all heaps are valid, False if at least one heap is corrupt.
Parameters
• print_errors: Print specific errors if heap corruption is found.
bool heap_caps_check_integrity(uint32_t caps, bool print_errors)
Check integrity of all heaps with the given capabilities.
Calls multi_heap_check on all heaps which share the given capabilities. Optionally print errors if the heaps are
corrupt.
See also heap_caps_check_integrity_all to check all heap memory in the system and
heap_caps_check_integrity_addr to check memory around a single address.
Return True if all heaps are valid, False if at least one heap is corrupt.
Parameters
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory
• print_errors: Print specific errors if heap corruption is found.
bool heap_caps_check_integrity_addr(intptr_t addr, bool print_errors)
Check integrity of heap memory around a given address.
This function can be used to check the integrity of a single region of heap memory, which contains the given
address.
This can be useful if debugging heap integrity for corruption at a known address, as it has a lower over-
head than checking all heap regions. Note that if the corrupt address moves around between runs (due to
timing or other factors) then this approach won’t work and you should call heap_caps_check_integrity or
heap_caps_check_integrity_all instead.
Note The entire heap region around the address is checked, not only the adjacent heap blocks.
Return True if the heap containing the specified address is valid, False if at least one heap is corrupt or the
address doesn’t belong to a heap region.
Parameters
• addr: Address in memory. Check for corruption in region containing this address.
• print_errors: Print specific errors if heap corruption is found.
void heap_caps_malloc_extmem_enable(size_t limit)
Enable malloc() in external memory and set limit below which malloc() attempts are placed in internal memory.
Espressif Systems 976
Submit Document Feedback
Release v4.4