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

Function ts_nstack_push

internal/cbm/extract_node_stack.h:52–66  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

50
51/* Push a node onto the stack, growing 2x if needed. */
52static inline void ts_nstack_push(TSNodeStack *s, TSNode node) {
53 if (s->count >= s->cap) {
54 int new_cap = s->cap ? s->cap * 2 : 512;
55 TSNode *new_items = (TSNode *)cbm_arena_alloc(s->scratch, (size_t)new_cap * sizeof(TSNode));
56 if (!new_items)
57 return; /* OOM: best-effort, stop growing */
58 if (s->items && s->count > 0) {
59 memcpy(new_items, s->items, (size_t)s->count * sizeof(TSNode));
60 }
61 /* Old s->items is abandoned in the arena — freed on arena_destroy. */
62 s->items = new_items;
63 s->cap = new_cap;
64 }
65 s->items[s->count++] = node;
66}
67
68/* Pop a node from the stack. Caller must check s->count > 0. */
69static inline TSNode ts_nstack_pop(TSNodeStack *s) {

Callers 15

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
parse_html_importsFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected