littlefs
littlefs copied to clipboard
about defining lfs_malloc/lfs_free as macros
Hi,
lfs_malloc()
and lfs_free()
are currently provided as functions using the system malloc
& free
this prevents the LittleFS from using RTOS memory allocation like the FreeRTOS pvPortMalloc()
& pvPortFree()
it is possible to consider using macros instead of example
#ifndef LFS_NO_MALLOC
#ifndef lfs_malloc
#define lfs_malloc malloc
#endif
#ifndef lfs_free
#define lfs_free free
#endif
#endif
regards Haithem.
Hi @rahmanih, it is currently possible to override lfs_malloc/lfs_free by providing your own lfs_utils.h:
https://github.com/littlefs-project/littlefs/blob/c733d9ec5776dfc949ec6dc71fa9ce3ff71de6e5/lfs_util.h#L11-L21
Though I've come to realize this is unnecessarily cumbersome for many util overrides, and having simple ifdefs as you mentioned would be better. It's something on my TODO list. There is some other config-related work I was batching it up with which is why I haven't gotten to it yet.
Improving things over here: https://github.com/littlefs-project/littlefs/pull/909
Let me know if anything looks wrong.