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

Function field_edge_exists

tests/test_pipeline.c:9188–9224  ·  view source on GitHub ↗

True when a node named src_name has an edge of edge_type to the Field * `field` OWNED BY `owner` (qualified name ends in ".owner.field"). The * name-only cross_file_edge_exists cannot tell two same-named fields apart, * which is exactly what the C member-access probes below must do. */

Source from the content-addressed store, hash-verified

9186 * name-only cross_file_edge_exists cannot tell two same-named fields apart,
9187 * which is exactly what the C member-access probes below must do. */
9188static bool field_edge_exists(cbm_store_t *s, const char *project, const char *src_name,
9189 const char *owner, const char *field, const char *edge_type) {
9190 char suffix[256];
9191 snprintf(suffix, sizeof(suffix), ".%s.%s", owner, field);
9192 size_t suffix_len = strlen(suffix);
9193 cbm_node_t *srcs = NULL;
9194 cbm_node_t *tgts = NULL;
9195 int sc = 0;
9196 int tc = 0;
9197 cbm_store_find_nodes_by_name(s, project, src_name, &srcs, &sc);
9198 cbm_store_find_nodes_by_name(s, project, field, &tgts, &tc);
9199 bool found = false;
9200 for (int i = 0; i < sc && !found; i++) {
9201 cbm_edge_t *edges = NULL;
9202 int ec = 0;
9203 cbm_store_find_edges_by_source_type(s, srcs[i].id, edge_type, &edges, &ec);
9204 for (int j = 0; j < ec && !found; j++) {
9205 for (int k = 0; k < tc && !found; k++) {
9206 const char *qn = tgts[k].qualified_name;
9207 size_t qn_len = qn ? strlen(qn) : 0;
9208 found = edges[j].target_id == tgts[k].id && tgts[k].label &&
9209 strcmp(tgts[k].label, "Field") == 0 && qn_len >= suffix_len &&
9210 strcmp(qn + qn_len - suffix_len, suffix) == 0;
9211 }
9212 }
9213 if (edges) {
9214 cbm_store_free_edges(edges, ec);
9215 }
9216 }
9217 if (srcs) {
9218 cbm_store_free_nodes(srcs, sc);
9219 }
9220 if (tgts) {
9221 cbm_store_free_nodes(tgts, tc);
9222 }
9223 return found;
9224}
9225
9226/* Number of edges of edge_type that END on the Field `field` owned by `owner`,
9227 * whatever their source: the call probes below must hold for a caller in any

Callers 1

Calls 4

cbm_store_free_edgesFunction · 0.85
cbm_store_free_nodesFunction · 0.85

Tested by

no test coverage detected