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

Function resolve_slash_prefix

src/pipeline/pass_pkgmap.c:1319–1347  ·  view source on GitHub ↗

Try slash-based prefix matching (Go: github.com/foo/bar/pkg/utils). * Returns heap QN or NULL. */

Source from the content-addressed store, hash-verified

1317/* Try slash-based prefix matching (Go: github.com/foo/bar/pkg/utils).
1318 * Returns heap QN or NULL. */
1319static char *resolve_slash_prefix(CBMHashTable *map, const char *module_path) {
1320 char *buf = strdup(module_path);
1321 if (!buf) {
1322 return NULL;
1323 }
1324 for (char *slash = buf + strlen(buf) - SKIP_ONE; slash > buf; slash--) {
1325 if (*slash != '/') {
1326 continue;
1327 }
1328 *slash = '\0';
1329 const char *base_qn = (const char *)cbm_ht_get(map, buf);
1330 if (!base_qn) {
1331 continue;
1332 }
1333 const char *subpath = module_path + (size_t)(slash - buf) + SKIP_ONE;
1334 char result[PKGMAP_PATH_BUF];
1335 snprintf(result, sizeof(result), "%s.%s", base_qn, subpath);
1336 /* Replace / with . in the appended part */
1337 for (char *c = result + strlen(base_qn) + SKIP_ONE; *c; c++) {
1338 if (*c == '/') {
1339 *c = '.';
1340 }
1341 }
1342 free(buf);
1343 return strdup(result);
1344 }
1345 free(buf);
1346 return NULL;
1347}
1348
1349/* Try dot-based prefix matching (Java: com.myorg.pkg.Foo).
1350 * Returns heap QN or NULL. */

Callers 1

Calls 1

cbm_ht_getFunction · 0.85

Tested by

no test coverage detected