The original TLSF PR (https://github.com/RIOT-OS/RIOT/pull/1215) contained a big patch that modified the TLSF API.
Vanilla TLSF functions take as a first argument a pointer to a "control block" which define a collection of memory pools. The allocation functions only work within the provided control block. The parch removes this parameters and creates a global control block.
-void* tlsf_malloc(tlsf_t tlsf, size_t size) +void* tlsf_malloc(size_t size)
There's some issues with that:
- The new API is not documented anywhere. If someone looks at the official TLSF repo, the functions are different to the RIOT pkg. - The patch removes the option to have multiple "control blocks" (that is, independent heap spaces). I want this feature for the Lua interpreter.
I propose to undo the parts of the patch that modify the TLSF api.
The pkg already adds a layer on top of TLSF that implements malloc/free/etc that is meant to be used by application programs. The global control block could be defined there. Additionally, I think that that layer should be in a proper C file that can be read by people and by Doxygen instead of in a patch.
I grep'd the RIOT source and the tlsf_* functions are not used anywhere, so this change should not break anything as long as the malloc-tlsf wrapper still works. The original PR says:
This PKG is not meant to be used by applicitions directly, but by the boards. The board's initialition code needs to call int tlsf_add_pool(void *mem, size_t bytes) for every free memory region it has.
Another issues is whether it is OK for modules to use private heaps. In the case of an interpreter, I think it is a good idea to be able to isolate the VM from the rest of the system.