diff --git a/2024/src/day2.zig b/2024/src/day2.zig index 9f76405..d69a445 100644 --- a/2024/src/day2.zig +++ b/2024/src/day2.zig @@ -18,6 +18,7 @@ pub fn main() !void { const allocator = gpa.allocator(); const input = try util.readAllInput(2, allocator); + defer allocator.free(input); var safe: u16 = 0; var safe_with_dampener: u16 = 0; diff --git a/2024/src/day3.zig b/2024/src/day3.zig index b2ac7ea..3d9a354 100644 --- a/2024/src/day3.zig +++ b/2024/src/day3.zig @@ -96,6 +96,7 @@ pub fn maybeScan(comptime T: type, window: *std.mem.WindowIterator(T)) !u32 { pub fn main() !void { const input = try util.readAllInput(3, allocator); + defer allocator.free(input); var mul = MulOp.init(); var window = std.mem.window(u8, input, 12, 1); @@ -107,3 +108,14 @@ pub fn main() !void { log.info("PART 1: {d}\n", .{p1}); log.info("PART 2: {d}\n", .{p2}); } + +test "memory" { + const input = try util.readAllInput(3, std.testing.allocator); + defer std.testing.allocator.free(input); + + var mul = MulOp.init(); + var window = std.mem.window(u8, input, 12, 1); + const res = try scanForUncorrupted(u8, &window, &mul, 1); + try std.testing.expect(res > 0); + +}