Chapter 2. API Reference
void multi_heap_aligned_free(multi_heap_handle_t heap, void *p)
free() a buffer aligned in a given heap.
Note This function is deprecated, consider using multi_heap_free() instead
Parameters
• heap: Handle to a registered heap.
• p: NULL, or a pointer previously returned from multi_heap_aligned_alloc() for the same heap.
void multi_heap_free(multi_heap_handle_t heap, void *p)
free() a buffer in a given heap.
Semantics are the same as standard free(), only the argument ‘p’must be NULL or have been allocated in
the specified heap.
Parameters
• heap: Handle to a registered heap.
• p: NULL, or a pointer previously returned from multi_heap_malloc() or multi_heap_realloc() for
the same heap.
void *multi_heap_realloc(multi_heap_handle_t heap, void *p, size_t size)
realloc() a buffer in a given heap.
Semantics are the same as standard realloc(), only the argument ‘p’must be NULL or have been allocated
in the specified heap.
Return New buffer of ‘size’containing contents of ‘p’, or NULL if reallocation failed.
Parameters
• heap: Handle to a registered heap.
• p: NULL, or a pointer previously returned from multi_heap_malloc() or multi_heap_realloc() for
the same heap.
• size: Desired new size for buffer.
size_t multi_heap_get_allocated_size(multi_heap_handle_t heap, void *p)
Return the size that a particular pointer was allocated with.
Return Size of the memory allocated at this block. May be more than the original size argument, due to
padding and minimum block sizes.
Parameters
• heap: Handle to a registered heap.
• p: Pointer, must have been previously returned from multi_heap_malloc() or multi_heap_realloc()
for the same heap.
multi_heap_handle_t multi_heap_register(void *start, size_t size)
Register a new heap for use.
This function initialises a heap at the specified address, and returns a handle for future heap operations.
There is no equivalent function for deregistering a heap - if all blocks in the heap are free, you can immediately
start using the memory for other purposes.
Return Handle of a new heap ready for use, or NULL if the heap region was too small to be initialised.
Parameters
• start: Start address of the memory to use for a new heap.
• size: Size (in bytes) of the new heap.
void multi_heap_set_lock(multi_heap_handle_t heap, void *lock)
Associate a private lock pointer with a heap.
The lock argument is supplied to the MULTI_HEAP_LOCK() and MULTI_HEAP_UNLOCK() macros, de-
fined in multi_heap_platform.h.
The lock in question must be recursive.
When the heap is first registered, the associated lock is NULL.
Parameters
• heap: Handle to a registered heap.
Espressif Systems 981
Submit Document Feedback
Release v4.4