[libc-commits] [libc] [libc] Implement dual freestore rotation for baremetal heap (PR #209811)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Fri Sep 4 17:03:04 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) {
----------------
SchrodingerZhu wrote:
I made it in heap because the logic couples with stores. Let me think about a proper logic.
https://github.com/llvm/llvm-project/pull/209811
More information about the libc-commits
mailing list