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

Function calls_append_args

src/pipeline/pass_calls.c:271–311  ·  view source on GitHub ↗

Insert an edge, splicing the call-site line (,"line":N) in before the closing * brace when one was captured. Mirrors finalize_and_emit() on the parallel path * so CALLS edges carry their source line regardless of resolution path. Restricted * to CALLS: route/config edge props feed full-only predump passes * (create_route_nodes/create_data_flows), so altering them desyncs full vs * incremental

Source from the content-addressed store, hash-verified

269 * (< 50 file) repos that take the sequential path (#514). Mirrors the parallel
270 * path's append_args_json shape so both pipelines agree. */
271static void calls_append_args(char *props, size_t cap, const CBMCall *call) {
272 if (!call || call->arg_count <= 0) {
273 return;
274 }
275 size_t len = strlen(props);
276 if (len < SKIP_ONE || props[len - SKIP_ONE] != '}') {
277 return;
278 }
279 /* Overwrite the trailing '}' and rebuild it after the args array. */
280 size_t pos = len - SKIP_ONE;
281 int n = snprintf(props + pos, cap - pos, ",\"args\":[");
282 if (n <= 0 || (size_t)n >= cap - pos) {
283 return;
284 }
285 pos += (size_t)n;
286 for (int i = 0; i < call->arg_count; i++) {
287 const CBMCallArg *a = &call->args[i];
288 char esc_e[CBM_SZ_256];
289 cbm_json_escape(esc_e, sizeof(esc_e), a->expr ? a->expr : "");
290 char one[CBM_SZ_512];
291 if (a->value) {
292 char esc_v[CBM_SZ_256];
293 cbm_json_escape(esc_v, sizeof(esc_v), a->value);
294 n = snprintf(one, sizeof(one), "%s{\"i\":%d,\"e\":\"%s\",\"v\":\"%s\"}",
295 i > 0 ? "," : "", a->index, esc_e, esc_v);
296 } else {
297 n = snprintf(one, sizeof(one), "%s{\"i\":%d,\"e\":\"%s\"}", i > 0 ? "," : "", a->index,
298 esc_e);
299 }
300 if (n <= 0 || (size_t)n >= cap - pos - PAIR_LEN) {
301 break; /* not enough room — close the array with what fits */
302 }
303 memcpy(props + pos, one, (size_t)n);
304 pos += (size_t)n;
305 }
306 if (pos + PAIR_LEN < cap) {
307 props[pos++] = ']';
308 props[pos++] = '}';
309 props[pos] = '\0';
310 }
311}
312
313static void calls_emit_edge(cbm_gbuf_t *gbuf, int64_t src, int64_t tgt, const char *type,
314 char *props, size_t cap, const CBMCall *call) {

Callers 1

calls_emit_edgeFunction · 0.85

Calls 1

cbm_json_escapeFunction · 0.85

Tested by

no test coverage detected