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

Function configures_fingerprint

tests/test_configlink.c:466–508  ·  view source on GitHub ↗

Collect the CONFIGURES edge set as a sorted, newline-joined * "src_qn|tgt_qn" fingerprint. Caller frees. */

Source from the content-addressed store, hash-verified

464/* Collect the CONFIGURES edge set as a sorted, newline-joined
465 * "src_qn|tgt_qn" fingerprint. Caller frees. */
466static char *configures_fingerprint(cbm_gbuf_t *gb) {
467 const cbm_gbuf_edge_t **edges = NULL;
468 int count = 0;
469 cbm_gbuf_find_edges_by_type(gb, "CONFIGURES", &edges, &count);
470
471 char **rows = calloc((size_t)(count > 0 ? count : 1), sizeof(*rows));
472 if (!rows) {
473 return NULL;
474 }
475 int n = 0;
476 for (int i = 0; i < count; i++) {
477 const cbm_gbuf_node_t *s = cbm_gbuf_find_by_id(gb, edges[i]->source_id);
478 const cbm_gbuf_node_t *t = cbm_gbuf_find_by_id(gb, edges[i]->target_id);
479 if (!s || !t || !s->qualified_name || !t->qualified_name) {
480 continue;
481 }
482 size_t len = strlen(s->qualified_name) + strlen(t->qualified_name) + 2;
483 rows[n] = malloc(len);
484 if (!rows[n]) {
485 break;
486 }
487 snprintf(rows[n], len, "%s|%s", s->qualified_name, t->qualified_name);
488 n++;
489 }
490 qsort(rows, (size_t)n, sizeof(*rows), cl_cmp_row);
491
492 size_t total = 1;
493 for (int i = 0; i < n; i++) {
494 total += strlen(rows[i]) + 1;
495 }
496 char *out = calloc(total, 1);
497 if (out) {
498 for (int i = 0; i < n; i++) {
499 strcat(out, rows[i]);
500 strcat(out, "\n");
501 }
502 }
503 for (int i = 0; i < n; i++) {
504 free(rows[i]);
505 }
506 free(rows);
507 return out;
508}
509
510/* Build a gbuf whose code-candidate count exceeds the collector's internal
511 * cap, inserting the candidates either forwards or backwards. */

Callers 1

test_configlink.cFile · 0.85

Calls 2

cbm_gbuf_find_by_idFunction · 0.85

Tested by

no test coverage detected