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

Function slab_map_lookup

src/foundation/slab_alloc.c:149–163  ·  view source on GitHub ↗

Lock-free. Returns the slab page whose base == (ptr & mask), or NULL if the * masked base is not a registered slab page (i.e. ptr is a plain heap block). */

Source from the content-addressed store, hash-verified

147/* Lock-free. Returns the slab page whose base == (ptr & mask), or NULL if the
148 * masked base is not a registered slab page (i.e. ptr is a plain heap block). */
149static slab_page_t *slab_map_lookup(uintptr_t base) {
150 size_t i1, i2, i3;
151 if (!slab_map_indices(base, &i1, &i2, &i3)) {
152 return NULL;
153 }
154 slab_map_l2_t *l2 = atomic_load_explicit(&g_slab_map_root[i1], memory_order_acquire);
155 if (!l2) {
156 return NULL;
157 }
158 slab_map_l3_t *l3 = atomic_load_explicit(&l2->e[i2], memory_order_acquire);
159 if (!l3) {
160 return NULL;
161 }
162 return atomic_load_explicit(&l3->e[i3], memory_order_acquire);
163}
164
165/* Cold path. Sets the leaf entry for `base` to `val` (page to register, NULL to
166 * unregister), allocating intermediate tables on demand. Returns false only if

Callers 2

slab_reallocFunction · 0.85
slab_freeFunction · 0.85

Calls 1

slab_map_indicesFunction · 0.85

Tested by

no test coverage detected