diff --git a/board.sx b/board.sx index 912a0f8..7bc76ca 100644 --- a/board.sx +++ b/board.sx @@ -202,7 +202,7 @@ pick_gem :: (board: *Board, rng: *Rng, col: i64, row: i64) -> Gem { // single gem character per cell. Suitable for snapshotting. board_dump :: (self: *Board) -> string { line_w := BOARD_COLS + 1; // 8 gem chars + newline - buf := cstring(BOARD_ROWS * line_w); + buf := alloc_string(BOARD_ROWS * line_w); for 0..BOARD_ROWS (row) { base := row * line_w; for 0..BOARD_COLS (col) { @@ -298,7 +298,7 @@ find_matches :: (b: *Board) -> MatchMask { // unambiguously as the empty set. Suitable for snapshotting. dump_matches :: (b: *Board, m: *MatchMask) -> string { line_w := BOARD_COLS + 1; // 8 cells + newline - buf := cstring(BOARD_ROWS * line_w); + buf := alloc_string(BOARD_ROWS * line_w); for 0..BOARD_ROWS (row) { base := row * line_w; for 0..BOARD_COLS (col) { diff --git a/main.sx b/main.sx index 520b61b..f1aba31 100644 --- a/main.sx +++ b/main.sx @@ -24,8 +24,6 @@ // libc is the implicit foreign-library handle the std allocators bind against; // reused here to read the deterministic-capture environment variables at startup. -getenv :: (name: [:0]u8) -> *u8 #foreign libc "getenv"; -strlen :: (s: *u8) -> usize #foreign libc "strlen"; // Fixed seed for the rendered board — the same seed tests/board_init.sx locks // as a snapshot, so the on-screen layout matches that golden gem-for-gem. @@ -116,14 +114,7 @@ build_ui :: () -> View { // M3TE_SELECT= forces a selection so the select-pop reaction can // be captured without injecting a tap. Absent → normal live behaviour. read_env :: (name: [:0]u8) -> ?string { - p := getenv(name); - addr : i64 = xx p; - if addr == 0 { return null; } - n := cast(i64) strlen(p); - if n == 0 { return ""; } - buf := cstring(n); - memcpy(buf.ptr, xx p, n); - buf + process.env(name) } // Digit arithmetic runs entirely in i64; the result converts to f32 only once at