code wiki / (root) / nx_buf_dyn.nx

nx_buf_dyn.nx

buildroot/runtime/nx_buf_dyn.nx

8496 B248 linesdepth 3pulls 3 transitivereach 783 importersview sourcekind tooltopic buf
docsdependenciesstructsconstsfunctions

about

nx_buf_dyn.nx -- dynamic growable byte buffer. Every formatter / builder / ELF emitter today picks a fixed upfront cap and bails on overflow. When the cap is wrong the caller has to recompile or re-mmap. This module gives them std::vector-style amortized growth: 2x doubling when full. API: buf = nx_bd_new(initial_cap) nx_bd_byte(buf, b) nx_bd_bytes(buf, src, n) nx_bd_u32(buf, v) -- LE nx_bd_u64(buf, v) -- LE nx_bd_str(buf, s) -- NUL-terminated, NUL not written nx_bd_strz(buf, s) -- NUL-terminated, NUL written nx_bd_clear(buf) -- len=0, keeps capacity buf.buf, buf.len -- direct access for emit Growth: 2x when full, never less than +64. Old bytes are memcpy'd to the new region; the old region is leaked (we don't have munmap discipline yet, and arenas reset wholesale anyway).

dependencies 1 imports · 11 importers

syscalls.nx nx_buf_dyn.nx nx_body_rest_registration.nx nx_body_rest_registration_candidat nx_body_skin_junction.nx nx_body_skin_junction_candidate_t3 nx_frontier_scan_review_candidate_ nx_game_page_sink_t221.nx nx_profile_fit_output_t320.nx nx_profile_region_map_candidate_t3 nx_solid_column_union_candidate_t3 nx_tool_run.nx

diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.

imports: syscalls.nx

imported by: nx_body_rest_registration.nxnx_body_rest_registration_candidate_t345.nxnx_body_skin_junction.nxnx_body_skin_junction_candidate_t345.nxnx_frontier_scan_review_candidate_t346.nxnx_game_page_sink_t221.nxnx_profile_fit_output_t320.nxnx_profile_region_map_candidate_t366.nxnx_solid_column_union_candidate_t365.nxnx_tool_run.nxnx_tool_run_evidence_candidate_t297.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_bd_new nx_bd_byte nx_bd_grow nx_bd_u32 nx_bd_byte ↻ nx_bd_bytes nx_bd_grow ↻ nx_bd_patch_u32 nx_bd_strz nx_bd_byte ↻ nx_bd_clear

structs

31struct NxBufDyn
205struct NxBufOwned { buf:*u8, len:i64, cap:i64, }

consts

37const NX_BD_BYTES: i64 = 24
38const NX_BD_MIN_CAP: i64 = 64
39const NX_BD_MIN_GROW: i64 = 64
206const NX_BO_BYTES:i64=24
207const NX_BO_I64_MAX:i64=9223372036854775807
208const NX_BO_INVALID:i64=-100
209const NX_BO_RANGE:i64=-101
210const NX_BO_CAPACITY:i64=-102
211const NX_BO_ALLOCATION:i64=-103
212const NX_BO_ALIAS:i64=-104
213const NX_BO_RELEASE:i64=-105

functions

41func nx_bd_new(initial_cap: i64) -> *NxBufDyn
called by 1: main
53func nx_bd_grow(b: *NxBufDyn, extra: i64) -> i64
70func nx_bd_byte(b: *NxBufDyn, v: i64) -> i64
77func nx_bd_bytes(b: *NxBufDyn, src: *u8, n: i64) -> i64
called by 1: main calls 1: nx_bd_grow
88func nx_bd_u16(b: *NxBufDyn, v: i64) -> i64
calls 1: nx_bd_byte
93func nx_bd_u32(b: *NxBufDyn, v: i64) -> i64
called by 1: main calls 1: nx_bd_byte
100func nx_bd_u64(b: *NxBufDyn, v: i64) -> i64
calls 1: nx_bd_byte
110func nx_bd_str(b: *NxBufDyn, s: *u8) -> i64
calls 1: nx_bd_byte
120func nx_bd_strz(b: *NxBufDyn, s: *u8) -> i64
called by 1: main calls 1: nx_bd_byte
129func nx_bd_clear(b: *NxBufDyn) -> i64
called by 1: main
136func nx_bd_patch_u32(b: *NxBufDyn, off: i64, v: i64) -> i64
called by 1: main
147func main() -> i64
214func nx_bo_state(b:*NxBufOwned)->i64
221func nx_bo_append(b:*NxBufOwned,src:*u8,n:i64,max_bytes:i64)->i64
243func nx_bo_release(b:*NxBufOwned)->i64