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

Function slab_refill

src/foundation/slab_alloc.c:246–261  ·  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

244/* Refill the thread-local free list: first reclaim any cross-thread frees
245 * queued on owned pages, then grow a fresh page if still empty. */
246static void slab_refill(slab_state_t *s) {
247 for (slab_page_t *p = s->pages; p; p = p->next) {
248 slab_free_node_t *rf = atomic_exchange_explicit(
249 &p->remote_free_head, (slab_free_node_t *)NULL, memory_order_acquire);
250 while (rf) {
251 slab_free_node_t *next = rf->next;
252 rf->next = s->freelist;
253 s->freelist = rf;
254 rf = next;
255 }
256 }
257 if (s->freelist) {
258 return;
259 }
260 (void)slab_grow(s);
261}
262
263/* Retire ownership and drop the owner guard for every page this thread owns.
264 * 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