[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 17:02:00 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:

And now I see that it was *originally* that way before this change. And I don't remember why. Well, if this ends up being untenable, no action required. Still, I have a hunch this might clean things up.

https://github.com/llvm/llvm-project/pull/209811


More information about the libc-commits mailing list