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

Function gc_consts

src/pipeline/pass_operator.c:1384–1418  ·  view source on GitHub ↗

The constants of package directory `dir` (its non-test Go files). */

Source from the content-addressed store, hash-verified

1382
1383/* The constants of package directory `dir` (its non-test Go files). */
1384static CBMHashTable *gc_consts(gc_t *g, const char *dir) {
1385 CBMHashTable *t = cbm_ht_get(g->consts, dir);
1386 if (t) {
1387 return t;
1388 }
1389 t = cbm_ht_create(0);
1390 char *key = cbm_mem_strdup(CBM_MEM_CLASS_OTHER, dir);
1391 if (!t || !key) {
1392 if (t) {
1393 cbm_ht_free(t);
1394 }
1395 cbm_free(CBM_MEM_CLASS_OTHER, key);
1396 return NULL;
1397 }
1398 cbm_ht_set(g->consts, key, t);
1399 size_t dl = strlen(dir);
1400 for (int i = 0; i < g->nfiles; i++) {
1401 const char *fp = g->files[i]->file_path;
1402 const char *slash = strrchr(fp, '/');
1403 size_t fdl = slash ? (size_t)(slash - fp) : 0;
1404 size_t fl = strlen(fp);
1405 if (fdl != dl || strncmp(fp, dir, dl) != 0 || !op_is_go(fp) ||
1406 (fl > OP_SLEN("_test.go") && strcmp(fp + fl - OP_SLEN("_test.go"), "_test.go") == 0)) {
1407 continue;
1408 }
1409 char path[CBM_SZ_4K];
1410 snprintf(path, sizeof(path), "%s/%s", g->ctx->repo_path, fp);
1411 char *text = op_read_file(path);
1412 if (text) {
1413 gc_scan_consts(t, text);
1414 cbm_free(CBM_MEM_CLASS_OTHER, text);
1415 }
1416 }
1417 return t;
1418}
1419
1420/* ── Values ── */
1421

Callers 1

gc_const_valueFunction · 0.85

Calls 9

cbm_ht_getFunction · 0.85
cbm_ht_createFunction · 0.85
cbm_mem_strdupFunction · 0.85
cbm_ht_freeFunction · 0.85
cbm_freeFunction · 0.85
cbm_ht_setFunction · 0.85
op_is_goFunction · 0.85
op_read_fileFunction · 0.85
gc_scan_constsFunction · 0.85

Tested by

no test coverage detected