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

Function calls_append_args

src/pipeline/pass_calls.c:287–331  ·  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

285 * (< 50 file) repos that take the sequential path (#514). Mirrors the parallel
286 * path's append_args_json shape so both pipelines agree. */
287static void calls_append_args(char *props, size_t cap, const CBMCall *call) {
288 if (!call || call->arg_count <= 0) {
289 return;
290 }
291 size_t len = strlen(props);
292 if (len < SKIP_ONE || props[len - SKIP_ONE] != '}') {
293 return;
294 }
295 /* Overwrite the trailing '}' and rebuild it after the args array. */
296 size_t pos = len - SKIP_ONE;
297 int n = snprintf(props + pos, cap - pos, ",\"args\":[");
298 if (n <= 0 || (size_t)n >= cap - pos) {
299 return;
300 }
301 pos += (size_t)n;
302 for (int i = 0; i < call->arg_count; i++) {
303 const CBMCallArg *a = &call->args[i];
304 char esc_e[CBM_SZ_256];
305 cbm_json_escape(esc_e, sizeof(esc_e), a->expr ? a->expr : "");
306 char one[CBM_SZ_512];
307 if (a->value) {
308 char esc_v[CBM_SZ_256];
309 cbm_json_escape(esc_v, sizeof(esc_v), a->value);
310 n = snprintf(one, sizeof(one), "%s{\"i\":%d,\"e\":\"%s\",\"v\":\"%s\"}",
311 i > 0 ? "," : "", a->index, esc_e, esc_v);
312 } else {
313 n = snprintf(one, sizeof(one), "%s{\"i\":%d,\"e\":\"%s\"}", i > 0 ? "," : "", a->index,
314 esc_e);
315 }
316 /* Add rather than subtract: pos is unsigned, so `cap - pos - PAIR_LEN`
317 * wraps once pos reaches cap - PAIR_LEN and stops bounding the memcpy
318 * below. The closing write at the end of this function already guards
319 * additively; match it. */
320 if (n <= 0 || pos + (size_t)n + PAIR_LEN >= cap) {
321 break; /* not enough room — close the array with what fits */
322 }
323 memcpy(props + pos, one, (size_t)n);
324 pos += (size_t)n;
325 }
326 if (pos + PAIR_LEN < cap) {
327 props[pos++] = ']';
328 props[pos++] = '}';
329 props[pos] = '\0';
330 }
331}
332
333static void calls_emit_edge(cbm_gbuf_t *gbuf, int64_t src, int64_t tgt, const char *type,
334 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