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

Function ts_nstack_init

internal/cbm/extract_node_stack.h:43–49  ·  view source on GitHub ↗

Initialize a stack with the given initial capacity, allocated from the * context's traversal scratch. Taking the context rather than an arena is * deliberate: it makes handing over ctx->arena, or a local alias of it, a type * error rather than a retention bug nobody notices. A context built without a * scratch falls back to ctx->arena, which is the behaviour that shipped before * #1997, so no

Source from the content-addressed store, hash-verified

41 * scratch falls back to ctx->arena, which is the behaviour that shipped before
42 * #1997, so no caller ever gets a NULL arena and silently loses nodes. */
43static inline void ts_nstack_init(TSNodeStack *s, const CBMExtractCtx *ctx, int initial_cap) {
44 CBMArena *arena = ctx->scratch ? ctx->scratch : ctx->arena;
45 s->scratch = arena;
46 s->items = (TSNode *)cbm_arena_alloc(arena, (size_t)initial_cap * sizeof(TSNode));
47 s->count = 0;
48 s->cap = s->items ? initial_cap : 0;
49}
50
51/* Push a node onto the stack, growing 2x if needed. */
52static inline void ts_nstack_push(TSNodeStack *s, TSNode node) {

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