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

Function c_build_module_prefixed

internal/cbm/lsp/c_lsp.c:2516–2527  ·  view source on GitHub ↗

Build " . " into a caller-provided stack buffer, replacing the vsnprintf("%s.%s") path (whose %s does a strlen of both args) that otherwise dominates the kernel cross-file resolve miss cascade. Uses the cached module_qn_len. Returns buf on success, or NULL if the result would not fit (caller falls back to cbm_arena_sprintf). The buffer is only read by the immediate registry looku

Source from the content-addressed store, hash-verified

2514// cbm_arena_sprintf). The buffer is only read by the immediate registry lookup — a
2515// stack lifetime is sufficient (the QN is never retained).
2516static const char *c_build_module_prefixed(const CLSPContext *ctx, const char *type_qn, char *buf,
2517 size_t bufsz) {
2518 size_t mlen = ctx->module_qn_len;
2519 size_t tlen = strlen(type_qn);
2520 if (mlen + 1 + tlen + 1 > bufsz)
2521 return NULL; // would truncate → fall back to arena sprintf
2522 memcpy(buf, ctx->module_qn, mlen);
2523 buf[mlen] = '.';
2524 memcpy(buf + mlen + 1, type_qn, tlen);
2525 buf[mlen + 1 + tlen] = '\0';
2526 return buf;
2527}
2528
2529// FNV-1a over (type_qn, 0xff separator, member_name) for the negative-lookup memo.
2530// 0 is remapped to 1 so it can serve as the empty-slot sentinel.

Callers 1

c_lookup_member_depthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected