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

Function go_stdlib_shared

internal/cbm/lsp/go_lsp.c:2215–2239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2213static _Atomic(go_stdlib_holder_t *) g_go_stdlib_shared;
2214
2215static const CBMTypeRegistry *go_stdlib_shared(void) {
2216 go_stdlib_holder_t *ready = atomic_load_explicit(&g_go_stdlib_shared, memory_order_acquire);
2217 if (ready)
2218 return &ready->reg;
2219 go_stdlib_holder_t *built = cbm_calloc(CBM_MEM_CLASS_OTHER, sizeof(*built));
2220 if (!built)
2221 return NULL;
2222 cbm_arena_init(&built->arena);
2223 if (built->arena.nblocks == 0) {
2224 cbm_free(CBM_MEM_CLASS_OTHER, built);
2225 return NULL;
2226 }
2227 cbm_registry_init(&built->reg, &built->arena);
2228 cbm_go_stdlib_register(&built->reg, &built->arena);
2229 cbm_registry_finalize(&built->reg);
2230 built->reg.read_only = true;
2231 go_stdlib_holder_t *expected = NULL;
2232 if (atomic_compare_exchange_strong_explicit(&g_go_stdlib_shared, &expected, built,
2233 memory_order_acq_rel, memory_order_acquire)) {
2234 return &built->reg;
2235 }
2236 cbm_arena_destroy(&built->arena);
2237 cbm_free(CBM_MEM_CLASS_OTHER, built);
2238 return &expected->reg;
2239}
2240
2241/* A per-file registry sees the stdlib: chained to the shared copy, or
2242 * registered into it when the shared copy cannot be built. */

Callers 1

go_registry_with_stdlibFunction · 0.85

Calls 7

cbm_callocFunction · 0.85
cbm_freeFunction · 0.85
cbm_registry_initFunction · 0.85
cbm_go_stdlib_registerFunction · 0.85
cbm_registry_finalizeFunction · 0.85
cbm_arena_initFunction · 0.50
cbm_arena_destroyFunction · 0.50

Tested by

no test coverage detected