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

Function append_complexity_props

src/pipeline/pass_complexity.c:79–100  ·  view source on GitHub ↗

Append transitive_loop_depth + recursive to a node's properties JSON object. */

Source from the content-addressed store, hash-verified

77
78/* Append transitive_loop_depth + recursive to a node's properties JSON object. */
79static void append_complexity_props(cbm_gbuf_node_t *node, int tld, bool recursive) {
80 const char *old = node->properties_json ? node->properties_json : "{}";
81 size_t olen = strlen(old);
82 if (olen < 2 || old[olen - 1] != '}') {
83 return; /* not a JSON object — leave untouched */
84 }
85 bool empty = (olen == 2); /* "{}" */
86 char *neu = malloc(olen + CBM_SZ_64);
87 if (!neu) {
88 return;
89 }
90 memcpy(neu, old, olen - 1); /* copy without trailing '}' */
91 int w =
92 snprintf(neu + (olen - 1), CBM_SZ_64, "%s\"transitive_loop_depth\":%d,\"recursive\":%s}",
93 empty ? "" : ",", tld, recursive ? "true" : "false");
94 if (w < 0) {
95 free(neu);
96 return;
97 }
98 free(node->properties_json);
99 node->properties_json = neu;
100}
101
102/* Memoized DFS: tld(id) = loop_depth(id) + max over CALLS-callees of tld(callee).
103 * state: 0=unvisited, 1=in-progress (back-edge → cycle), 2=done. */

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected