diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 00:22:27 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:00:59 -0300 |
| commit | 1b12f7aadaf0e0a4570a5985900f61d0fb897f79 (patch) | |
| tree | 2563f00aa47d3ef39ef1647482ba5d19bc1373a1 /src/pardes.zig | |
| parent | b283824eed0703ae9b89f2af520354046146b855 (diff) | |
| download | pardes-1b12f7aadaf0e0a4570a5985900f61d0fb897f79.tar.gz pardes-1b12f7aadaf0e0a4570a5985900f61d0fb897f79.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 16 |
1 files changed, 2 insertions, 14 deletions
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; } }; |
