From 1b12f7aadaf0e0a4570a5985900f61d0fb897f79 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 00:22:27 -0300 Subject: surface: a frame's images are a std.ArrayList(ImagePlace), where they were a slice of optionals grown by hand (appendImagePlace's doubling realloc, nimages beside it) whose slots were never null: every reader's `orelse continue` and `.?` go (gui, tui, terminal, TerminalImages, ninep/screen, test/pdf.zig, kitty and the two PDF benches); macos.zig's loop the same, passing ast-check but not built here Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/pardes.zig | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 11cb762a..fb26840b 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -4478,7 +4478,7 @@ pub const Pardes = struct { for (&p.surface.body_layers) |*layer| gpa.free(layer.cells); for (&p.surface.tag_layers) |*layer| gpa.free(layer.cells); p.presentation.deinit(gpa); - if (p.surface.images.len > 0) gpa.free(p.surface.images); + p.surface.images.deinit(gpa); gpa.destroy(p); } @@ -7573,19 +7573,7 @@ pub const Pardes = struct { pub const render = draw.render; pub fn appendImagePlace(p: *Pardes, place: ImagePlace) bool { - const s = &p.surface; - if (s.nimages == s.images.len) { - const old_len = s.images.len; - const new_len = @max(@as(usize, 4), std.math.mul(usize, @max(old_len, 1), 2) catch return false); - const grown = if (old_len == 0) - p.gpa.alloc(?ImagePlace, new_len) catch return false - else - p.gpa.realloc(s.images, new_len) catch return false; - @memset(grown[old_len..], null); - s.images = grown; - } - s.images[s.nimages] = place; - s.nimages += 1; + p.surface.images.append(p.gpa, place) catch return false; return true; } }; -- cgit v1.3