Skip to content

Commit

Permalink
Merge branch 'Deprinz2015-feature-rain' into feature-rain
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesrocket committed Sep 5, 2024
2 parents e74212d + 4b7e9a7 commit a73ce17
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ const Core = struct {
_ = tb.tb_shutdown();
}

if (self.lines != null) {
self.lines.?.deinit();
if (self.lines) |lines| {
for (lines.items) |line| {
self.allocator.free(line);
}
lines.deinit();
}

if (self.width_gaps != null) {
Expand Down Expand Up @@ -302,7 +305,8 @@ fn printCells(core: *Core, handler: *Handler, rand: std.rand.Random) !void {
const slice = try arr.toOwnedSlice();

if (core.lines.?.items.len == core.height) {
_ = core.lines.?.pop();
const old_line = core.lines.?.pop();
core.allocator.free(old_line);
try core.lines.?.insert(0, slice);
break :height;
}
Expand Down

0 comments on commit a73ce17

Please sign in to comment.