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

Function append_complexity_props

src/pipeline/pass_complexity.c:83–104  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

81
82/* Append transitive_loop_depth + recursive to a node's properties JSON object. */
83static void append_complexity_props(cbm_gbuf_node_t *node, int tld, bool recursive) {
84 const char *old = node->properties_json ? node->properties_json : "{}";
85 size_t olen = strlen(old);
86 if (olen < 2 || old[olen - 1] != '}') {
87 return; /* not a JSON object — leave untouched */
88 }
89 bool empty = (olen == 2); /* "{}" */
90 char *neu = cbm_alloc(CBM_MEM_CLASS_OTHER, olen + CBM_SZ_64);
91 if (!neu) {
92 return;
93 }
94 memcpy(neu, old, olen - 1); /* copy without trailing '}' */
95 int w =
96 snprintf(neu + (olen - 1), CBM_SZ_64, "%s\"transitive_loop_depth\":%d,\"recursive\":%s}",
97 empty ? "" : ",", tld, recursive ? "true" : "false");
98 if (w < 0) {
99 cbm_free(CBM_MEM_CLASS_OTHER, neu);
100 return;
101 }
102 (void)cbm_gbuf_node_set_properties_json(node, neu);
103 cbm_free(CBM_MEM_CLASS_OTHER, neu);
104}
105
106/* Content-only node order: qualified_name, then file path and start line.
107 * Never the temp id: extract workers draw ids from one shared counter, so id

Callers 1

Calls 3

cbm_allocFunction · 0.85
cbm_freeFunction · 0.85

Tested by

no test coverage detected