Espressif ESP32-S2 Programming Manual page 986

Table of Contents

Advertisement

Chapter 2. API Reference
Return A pointer to the memory allocated on success, NULL on failure
Parameters
• alignment: How the pointer received needs to be aligned must be a power of two
• n: Number of continuing chunks of memory to allocate
• size: Size, in bytes, of a chunk of memory to allocate
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory to be returned
void *heap_caps_calloc(size_t n, size_t size, uint32_t caps)
Allocate a chunk of memory which has the given capabilities. The initialized value in the memory is set to
zero.
Equivalent semantics to libc calloc(), for capability-aware memory.
In IDF, calloc(p) is equivalent to heap_caps_calloc(p, MALLOC_CAP_8BIT).
Return A pointer to the memory allocated on success, NULL on failure
Parameters
• n: Number of continuing chunks of memory to allocate
• size: Size, in bytes, of a chunk of memory to allocate
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory to be returned
size_t heap_caps_get_total_size(uint32_t caps)
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.
Return total size in bytes
Parameters
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory
size_t heap_caps_get_free_size(uint32_t caps)
Get the total free 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 free
space they have.
Note that because of heap fragmentation it is probably not possible to allocate a single block of memory of this
size. Use heap_caps_get_largest_free_block() for this purpose.
Return Amount of free bytes in the regions
Parameters
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory
size_t heap_caps_get_minimum_free_size(uint32_t caps)
Get the total minimum free memory of all regions with the given capabilities.
This adds all the low water marks of the regions capable of delivering the memory with the given capabilities.
Note the result may be less than the global all-time minimum available heap of this kind, as"low water marks"
are tracked per-region. Individual regions' heaps may have reached their"low water marks" at different points
in time. However this result still gives a "worst case"indication for all-time minimum free heap.
Return Amount of free bytes in the regions
Parameters
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory
size_t heap_caps_get_largest_free_block(uint32_t caps)
Get the largest free block of memory able to be allocated with the given capabilities.
Returns the largest value of s for which heap_caps_malloc(s, caps) will succeed.
Return Size of largest free block in bytes.
Parameters
• caps: Bitwise OR of MALLOC_CAP_* flags indicating the type of memory
Espressif Systems
975
Submit Document Feedback
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF