The function will find a suitable free block that can contain
the malloc size at the given address in the memory pool, split
the free block to create the block that will contain the allocated
memory, update the status of the newly created blocks (free / used)
and return the pointer to the memory allocated at the given address.
If no block is found (the status of the heap doesn't allow for an
allocation at the given address) the function will return NULL.
This commit adds a return boolean value to the tlsf_walker
function allowing users to interrupt the traversal of the
pool when returning from any call to the tlsf_walker.
In this commit:
- We add a weak delcaration of tlsf_check_hook() in tlsf.h.
- We call tlsf_check_hook() in tlsf_check() if the function has a defintion
This hook function allows the user to implement application specific checks on
the memory of every free blocks (e.g. check for memory corruption).
Note: block_absorb() is called in tlsf_free(), which is eventually called in multi_heap_free()
after the memory fill is done. As the block_absorb merges 2 blocks together, the previous block
header of the merged block is now in the middle of the memory block but not filled with 0xfe.
- Remove dependencies with the heap component of the IDF.
- The tlsf_poison_fill_region_hook() function is defined as weak in IDF and checked for NULL
in block_absorb() function in order to minimize the dependencies between IDF and the TLSF.
- The the implementation of tlsf_poison_fill_region_hook() must be provided at the discretion
of the user.