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

Function make_edge_key

src/graph_buffer/graph_buffer.c:179–198  ·  view source on GitHub ↗

IMPORTS edges carry exactly one imported symbol's local_name (#768): two * named imports from the same specifier resolve to the same (source, * target) pair but are distinct symbols. Key on local_name too so the * second import doesn't dedup-collide with and overwrite the first — * every pass that walks IMPORTS edges (pass_calls.c, pass_usages.c, * pass_semantic.c, pass_lsp_cross.c) expects o

Source from the content-addressed store, hash-verified

177 * JSON slice (control characters must be \u-escaped in JSON), so hash keys
178 * can never collide with verbatim keys. */
179static void make_edge_key(char *buf, size_t bufsz, int64_t src, int64_t tgt, const char *type,
180 const char *properties_json) {
181 if (properties_json && strcmp(type, "IMPORTS") == 0) {
182 static const char local_name_key[] = "\"local_name\":\"";
183 const char *ln = strstr(properties_json, local_name_key);
184 if (ln) {
185 ln += sizeof(local_name_key) - 1;
186 const char *end = strchr(ln, '"');
187 size_t ln_len = end ? (size_t)(end - ln) : strlen(ln);
188 int n = snprintf(buf, bufsz, "%lld:%lld:%s:%.*s", (long long)src, (long long)tgt, type,
189 (int)ln_len, ln);
190 if (n < 0 || (size_t)n >= bufsz) {
191 snprintf(buf, bufsz, "%lld:%lld:%s:\x01%016llx", (long long)src, (long long)tgt,
192 type, (unsigned long long)fnv1a64(ln, ln_len));
193 }
194 return;
195 }
196 }
197 snprintf(buf, bufsz, "%lld:%lld:%s", (long long)src, (long long)tgt, type);
198}
199
200static void make_src_type_key(char *buf, size_t bufsz, int64_t src, const char *type) {
201 snprintf(buf, bufsz, "%lld:%s", (long long)src, type);

Callers 3

unindex_edgeFunction · 0.85
cbm_gbuf_insert_edgeFunction · 0.85

Calls 1

fnv1a64Function · 0.85

Tested by

no test coverage detected