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

Function cs_brace_push

internal/cbm/doclink_cs.c:1244–1266  ·  view source on GitHub ↗

A new entry of the brace list; its index, or CBM_NOT_FOUND. */

Source from the content-addressed store, hash-verified

1242
1243/* A new entry of the brace list; its index, or CBM_NOT_FOUND. */
1244static int cs_brace_push(cs_scan_t *s, uint32_t pos, char kind) {
1245 if (s->failed) {
1246 return CBM_NOT_FOUND;
1247 }
1248 if (s->nbraces >= s->cap_braces) {
1249 int ncap = s->cap_braces ? s->cap_braces * PAIR_LEN : CS_BRACES_INIT;
1250 cs_brace_t *grown = (cs_brace_t *)cs_tmp_alloc(s, (size_t)ncap * sizeof(*grown));
1251 if (!grown) {
1252 return CBM_NOT_FOUND;
1253 }
1254 if (s->nbraces > 0) {
1255 memcpy(grown, s->braces, (size_t)s->nbraces * sizeof(*grown));
1256 }
1257 s->braces = grown;
1258 s->cap_braces = ncap;
1259 }
1260 s->braces[s->nbraces] = (cs_brace_t){.pos = pos,
1261 .row = cs_row_of(s, pos),
1262 .match = CBM_NOT_FOUND,
1263 .alias = CBM_NOT_FOUND,
1264 .kind = kind};
1265 return s->nbraces++;
1266}
1267
1268/* Brace `b` is open now: it goes on top of the open braces. */
1269static bool cs_open_push(cs_scan_t *s, int b) {

Callers 2

cs_lex_braceFunction · 0.85
cs_lex_branchFunction · 0.85

Calls 2

cs_tmp_allocFunction · 0.85
cs_row_ofFunction · 0.85

Tested by

no test coverage detected