Skip to content

Commit 6392a98

Browse files
committed
Day 16 part 2: fix nested deinit
1 parent 5ccbb00 commit 6392a98

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

day16/part2.zig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ const Packet = struct {
5151

5252
fn deinit(self: *Packet, allocator: *std.mem.Allocator) void {
5353
if (self.type != 4) {
54-
// TODO fix deinit
55-
// for (self.payload.operator.items) |packet| {
56-
// packet.deinit(allocator);
57-
// }
54+
var op: [*]Packet = self.payload.operator.items.ptr;
55+
var i: u32 = 0;
56+
while (i < self.payload.operator.items.len) : (i += 1) {
57+
op[i].deinit(allocator);
58+
}
5859
self.payload.operator.deinit(allocator);
5960
}
6061
}

0 commit comments

Comments
 (0)