Commit 48bb991
committed
Replace first-fit memory allocator with TLSF
This implements Two-Level Segregated Fit (TLSF) allocator optimized for
real-time scenarios:
- O(1) malloc/free via bitmap-based segregated free lists
- Branchless clz/ctz using mask-based shifts for RV32I compatibility
- Immediate coalescing on free() to minimize fragmentation
- Configurable FL_INDEX_MAX via CONFIG_TLSF_FL_INDEX_MAX
- Bounds validation in block_remove/block_insert with panic on corruption
- Sentinel placement validation in mo_heap_init
- Block header sanity checks in free() to detect double-free
Test coverage:
- Block coalescing verification
- Realloc in-place growth
- Block splitting logic
- Heap exhaustion handling
- FL/SL boundary allocations
- Alignment verification
- Bitmap stress tests1 parent 91f47ca commit 48bb991
4 files changed
Lines changed: 1099 additions & 207 deletions
0 commit comments