TLSF-based global memory allocator. More...
TLSF-based global memory allocator.
This is a malloc/free implementation built on top of the TLSF allocator. It defines a global tlsf_control block and performs allocations on that block. This implementation replaces the system malloc
Additionally, the calls to TLSF are wrapped in irq_disable()/irq_restore(), to make it thread-safe.
If this module is used as the system memory allocator, then the global memory control block should be initialized as the first thing before the stdlib is used. Boards should use tlsf_add_global_pool() at startup to add all the memory regions they want to make available for dynamic allocation via malloc().
Files | |
file | tlsf-malloc.h |
TLSF-based global memory allocator. | |
file | tlsf-malloc-internal.h |
Data Structures | |
struct | tlsf_size_container_t |
Struct to hold the total sizes of free and used blocks Used for tlsf_size_walker() More... | |
Functions | |
void | tlsf_size_walker (void *ptr, size_t size, int used, void *user) |
Walk the memory pool to print all block sizes and to calculate the total amount of free and used block sizes. | |
int | tlsf_add_global_pool (void *mem, size_t bytes) |
Add an area of memory to the global allocator pool. | |
tlsf_t | _tlsf_get_global_control (void) |
Get a pointer to the global tlsf_control block. | |
tlsf_t _tlsf_get_global_control | ( | void | ) |
Get a pointer to the global tlsf_control block.
Use for debugging purposes only.
int tlsf_add_global_pool | ( | void * | mem, |
size_t | bytes | ||
) |
Add an area of memory to the global allocator pool.
The first time this function is called, it will automatically perform a tlsf_create() on the global tlsf_control block.
mem | Pointer to memory area. Should be aligned to 4 bytes. |
bytes | Size in bytes of the memory area. |
void tlsf_size_walker | ( | void * | ptr, |
size_t | size, | ||
int | used, | ||
void * | user | ||
) |
Walk the memory pool to print all block sizes and to calculate the total amount of free and used block sizes.
ptr | Pointer to the current block. |
size | Size of the current block at ptr . |
used | Shows whether the current block is used or free. |
user | Custom data expected to be of type pointer to tlsf_size_container_t |