[libc-commits] [libc] [libc] Implement dual freestore rotation for baremetal heap (PR #209811)
Daniel Thornburgh via libc-commits
libc-commits at lists.llvm.org
Fri Sep 4 16:59:12 PDT 2026
================
@@ -68,15 +83,79 @@ class FreeListHeap {
bool is_valid_ptr(const void *ptr) const { return ptr >= begin && ptr < end; }
+ /// The store that allocations are served from.
+ LIBC_INLINE FreeStore &active_free_store() { return free_stores[active]; }
+
+ /// @returns The index of the store that receives newly freed blocks. With a
+ /// single free store this is the active store itself, so freed memory is
+ /// immediately available again.
+ LIBC_INLINE size_t quarantine_store_index() const {
+ return (active + 1) % NUM_FREE_STORES;
+ }
+
+ /// @returns Whether `neighbor`, a free block adjacent to a block owned by
+ /// `store_index`, can be merged into it.
+ LIBC_INLINE static bool can_merge(BlockRef neighbor, size_t store_index) {
----------------
mysterymath wrote:
This logic feels like it belongs on block; maybe transferring a block to another free store index coalesces? Unsure. It does feel like having the coalescing logic in the heap is oddly high-level.
https://github.com/llvm/llvm-project/pull/209811
More information about the libc-commits
mailing list