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

Function slab_map_lookup

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

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