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

Function resolve_slash_prefix

src/pipeline/pass_pkgmap.c:1019–1047  ·  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

1017/* Try slash-based prefix matching (Go: github.com/foo/bar/pkg/utils).
1018 * Returns heap QN or NULL. */
1019static char *resolve_slash_prefix(CBMHashTable *map, const char *module_path) {
1020 char *buf = strdup(module_path);
1021 if (!buf) {
1022 return NULL;
1023 }
1024 for (char *slash = buf + strlen(buf) - SKIP_ONE; slash > buf; slash--) {
1025 if (*slash != '/') {
1026 continue;
1027 }
1028 *slash = '\0';
1029 const char *base_qn = (const char *)cbm_ht_get(map, buf);
1030 if (!base_qn) {
1031 continue;
1032 }
1033 const char *subpath = module_path + (size_t)(slash - buf) + SKIP_ONE;
1034 char result[PKGMAP_PATH_BUF];
1035 snprintf(result, sizeof(result), "%s.%s", base_qn, subpath);
1036 /* Replace / with . in the appended part */
1037 for (char *c = result + strlen(base_qn) + SKIP_ONE; *c; c++) {
1038 if (*c == '/') {
1039 *c = '.';
1040 }
1041 }
1042 free(buf);
1043 return strdup(result);
1044 }
1045 free(buf);
1046 return NULL;
1047}
1048
1049/* Try dot-based prefix matching (Java: com.myorg.pkg.Foo).
1050 * Returns heap QN or NULL. */

Callers 1

Calls 1

cbm_ht_getFunction · 0.85

Tested by

no test coverage detected