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

Function cs_walk_push

internal/cbm/doclink_cs.c:2288–2306  ·  view source on GitHub ↗

Go into `node`: its children are collected next. false when memory ran out. */

Source from the content-addressed store, hash-verified

2286
2287/* Go into `node`: its children are collected next. false when memory ran out. */
2288static bool cs_walk_push(cs_scan_t *s, cs_walk_stack_t *w, TSNode node, int owner) {
2289 if (ts_node_is_null(node)) {
2290 return true;
2291 }
2292 if (w->count >= w->cap) {
2293 int ncap = w->cap ? w->cap * PAIR_LEN : CS_HEADS_INIT;
2294 cs_walk_t *grown = (cs_walk_t *)cs_tmp_alloc(s, (size_t)ncap * sizeof(*grown));
2295 if (!grown) {
2296 return false;
2297 }
2298 if (w->count > 0) {
2299 memcpy(grown, w->frames, (size_t)w->count * sizeof(*grown));
2300 }
2301 w->frames = grown;
2302 w->cap = ncap;
2303 }
2304 w->frames[w->count++] = (cs_walk_t){.kids = cs_kids(node), .owner = owner};
2305 return true;
2306}
2307
2308/* One child `c` of a collected node: record what it declares and go into it
2309 * where declarations can sit. false when memory ran out. */

Callers 2

cs_collect_childFunction · 0.85
cs_collectFunction · 0.85

Calls 2

cs_tmp_allocFunction · 0.85
cs_kidsFunction · 0.85

Tested by

no test coverage detected