MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / slab_refill

Function slab_refill

src/foundation/slab_alloc.c:243–258  ·  view source on GitHub ↗

Refill the thread-local free list: first reclaim any cross-thread frees * queued on owned pages, then grow a fresh page if still empty. */

Source from the content-addressed store, hash-verified

241/* Refill the thread-local free list: first reclaim any cross-thread frees
242 * queued on owned pages, then grow a fresh page if still empty. */
243static void slab_refill(slab_state_t *s) {
244 for (slab_page_t *p = s->pages; p; p = p->next) {
245 slab_free_node_t *rf = atomic_exchange_explicit(
246 &p->remote_free_head, (slab_free_node_t *)NULL, memory_order_acquire);
247 while (rf) {
248 slab_free_node_t *next = rf->next;
249 rf->next = s->freelist;
250 s->freelist = rf;
251 rf = next;
252 }
253 }
254 if (s->freelist) {
255 return;
256 }
257 (void)slab_grow(s);
258}
259
260/* Retire ownership and drop the owner guard for every page this thread owns.
261 * A page with no live chunks is freed immediately; a page still holding

Callers 1

slab_mallocFunction · 0.85

Calls 1

slab_growFunction · 0.85

Tested by

no test coverage detected