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

Function doc_code_dirs

src/pipeline/pass_semantic_edges.c:2516–2540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2514}
2515
2516static CBMHashTable *doc_code_dirs(const doc_files_t *df) {
2517 CBMHashTable *dirs = cbm_ht_create_in(CBM_MEM_CLASS_SEMANTIC, CBM_SZ_256);
2518 for (int i = 0; dirs && i < df->count; i++) {
2519 const char *path = df->node[i]->file_path;
2520 if (df->off[i + SKIP_ONE] == df->off[i]) {
2521 continue;
2522 }
2523 for (const char *p = strchr(path, '/'); p; p = strchr(p + SKIP_ONE, '/')) {
2524 size_t n = (size_t)(p - path);
2525 char *key = cbm_alloc(CBM_MEM_CLASS_SEMANTIC, n + SKIP_ONE);
2526 if (!key) {
2527 doc_code_dirs_free(dirs);
2528 return NULL;
2529 }
2530 memcpy(key, path, n);
2531 key[n] = '\0';
2532 if (cbm_ht_has(dirs, key)) {
2533 cbm_free(CBM_MEM_CLASS_SEMANTIC, key);
2534 } else {
2535 cbm_ht_set(dirs, key, (void *)(intptr_t)SKIP_ONE);
2536 }
2537 }
2538 }
2539 return dirs;
2540}
2541
2542/* A candidate's position: inside the home (or the home folder itself),
2543 * outside it, or no position (the home is the repository root). */

Callers 1

doc_place_buildFunction · 0.85

Calls 6

cbm_ht_create_inFunction · 0.85
cbm_allocFunction · 0.85
doc_code_dirs_freeFunction · 0.85
cbm_ht_hasFunction · 0.85
cbm_freeFunction · 0.85
cbm_ht_setFunction · 0.85

Tested by

no test coverage detected