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

Function gc_args

src/pipeline/pass_operator.c:1101–1133  ·  view source on GitHub ↗

The top-level comma-separated parts of the list opened at `open` ('('). * Returns their count (at most `max`); *end: the closing ')'. */

Source from the content-addressed store, hash-verified

1099/* The top-level comma-separated parts of the list opened at `open` ('(').
1100 * Returns their count (at most `max`); *end: the closing ')'. */
1101static int gc_args(const char *open, const char *starts[], size_t lens[], int max,
1102 const char **end) {
1103 int n = 0;
1104 int depth = 0;
1105 const char *start = open + SKIP_ONE;
1106 for (const char *p = open; *p;) {
1107 const char *q = gc_skip(p);
1108 if (q != p) {
1109 p = q;
1110 continue;
1111 }
1112 if (strchr("([{", *p)) {
1113 depth++;
1114 } else if (strchr(")]}", *p)) {
1115 depth--;
1116 if (depth == 0) {
1117 if (n < max && p > start) {
1118 starts[n] = start;
1119 lens[n++] = (size_t)(p - start);
1120 }
1121 *end = p;
1122 return n;
1123 }
1124 } else if (*p == ',' && depth == SKIP_ONE && n < max) {
1125 starts[n] = start;
1126 lens[n++] = (size_t)(p - start);
1127 start = p + SKIP_ONE;
1128 }
1129 p++;
1130 }
1131 *end = open + strlen(open);
1132 return n;
1133}
1134
1135static void gc_trim(const char **s, size_t *n) {
1136 while (*n && strchr(" \t\r\n", **s)) {

Callers 5

gc_body_loadsFunction · 0.85
gc_summarizeFunction · 0.85
gc_scan_constsFunction · 0.85
gc_evalFunction · 0.85
gc_link_callFunction · 0.85

Calls 1

gc_skipFunction · 0.85

Tested by

no test coverage detected