TLSF memory allocator. Less free flash, moar free ram. (#3572)

* add tlsf as submodule
* libs: tlsf
* Furi: tlsf as allocator
* Furi: heap walker
* shmal fixshesh
* f18: tlsf
* PVS: ignore tlsf
* I like to moving
* merge upcoming changes
* memmgr: alloc aligned, realloc
* Furi: distinct name for auxiliary memory pool
* Furi: put idle and timer thread to mem2
* Furi: fix smal things in allocator
* Furi: remove aligned_free. Use free instead.
* aligned_malloc -> aligned_alloc
* aligned_alloc, parameters order
* aligned_alloc: check that alignment is correct
* unit test: malloc
* unit tests: realloc and test with memory fragmentation
* unit tests: aligned_alloc
* update api
* updater: properly read large update file

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Sergei Gavrilov
2024-05-16 01:47:21 +10:00
committed by SG
parent 63403bbae2
commit e90dc38e4d
21 changed files with 628 additions and 645 deletions
+1
View File
@@ -13,6 +13,7 @@ env.Append(
libs = env.BuildModules(
[
"tlsf",
"mlib",
"stm32wb",
"freertos",
+4 -4
View File
@@ -466,7 +466,7 @@ static bool elf_load_section_data(ELFFile* elf, ELFSection* section, Elf32_Shdr*
return true;
}
section->data = aligned_malloc(section_header->sh_size, section_header->sh_addralign);
section->data = aligned_alloc(section_header->sh_addralign, section_header->sh_size);
section->size = section_header->sh_size;
if(section_header->sh_type == SHT_NOBITS) {
@@ -718,7 +718,7 @@ static bool elf_relocate_fast(ELFFile* elf, ELFSection* s) {
}
}
aligned_free(s->fast_rel->data);
free(s->fast_rel->data);
free(s->fast_rel);
s->fast_rel = NULL;
@@ -785,10 +785,10 @@ void elf_file_free(ELFFile* elf) {
ELFSectionDict_next(it)) {
const ELFSectionDict_itref_t* itref = ELFSectionDict_cref(it);
if(itref->value.data) {
aligned_free(itref->value.data);
free(itref->value.data);
}
if(itref->value.fast_rel) {
aligned_free(itref->value.fast_rel->data);
free(itref->value.fast_rel->data);
free(itref->value.fast_rel);
}
free((void*)itref->key);
Submodule
+1
Submodule lib/tlsf added at 8fc595fe22
+21
View File
@@ -0,0 +1,21 @@
Import("env")
env.Append(
CPPPATH=[
"#/lib/tlsf",
],
)
libenv = env.Clone(FW_LIB_NAME="tlsf")
libenv.ApplyLibFlags()
libenv.Append(
CPPDEFINES=[],
)
sources = [File("tlsf/tlsf.c")]
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")