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

Function ts_nstack_push

internal/cbm/extract_node_stack.h:33–47  ·  view source on GitHub ↗

Push a node onto the stack, growing 2x if needed. */

Source from the content-addressed store, hash-verified

31
32/* Push a node onto the stack, growing 2x if needed. */
33static inline void ts_nstack_push(TSNodeStack *s, CBMArena *arena, TSNode node) {
34 if (s->count >= s->cap) {
35 int new_cap = s->cap ? s->cap * 2 : 512;
36 TSNode *new_items = (TSNode *)cbm_arena_alloc(arena, (size_t)new_cap * sizeof(TSNode));
37 if (!new_items)
38 return; /* OOM: best-effort, stop growing */
39 if (s->items && s->count > 0) {
40 memcpy(new_items, s->items, (size_t)s->count * sizeof(TSNode));
41 }
42 /* Old s->items is abandoned in the arena — freed on arena_destroy. */
43 s->items = new_items;
44 s->cap = new_cap;
45 }
46 s->items[s->count++] = node;
47}
48
49/* Pop a node from the stack. Caller must check s->count > 0. */
50static inline TSNode ts_nstack_pop(TSNodeStack *s) {

Callers 15

walk_usagesFunction · 0.85
walk_es_importsFunction · 0.85
parse_zig_importsFunction · 0.85
walk_wolfram_importsFunction · 0.85
parse_hare_importsFunction · 0.85
parse_pascal_importsFunction · 0.85
parse_powershell_importsFunction · 0.85
parse_lisp_importsFunction · 0.85
parse_starlark_importsFunction · 0.85
parse_tcl_importsFunction · 0.85
parse_teal_importsFunction · 0.85
parse_zsh_importsFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected