| ... | ... | @@ -13,6 +13,8 @@ pub fn Main(comptime T: type) type { |
| 13 | 13 | pub fn do() !void { |
| 14 | 14 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; |
| 15 | 15 | const alloc = &gpa.allocator; |
| 16 | defer _ = gpa.deinit(); |
| 17 | |
| 16 | 18 | const max_size = std.math.maxInt(usize); |
| 17 | 19 | |
| 18 | 20 | // |
| ... | ... | @@ -38,8 +40,12 @@ pub fn Main(comptime T: type) type { |
| 38 | 40 | |
| 39 | 41 | var line_num: usize = 1; |
| 40 | 42 | std.debug.print("\n", .{}); |
| 43 | |
| 44 | const arena = &std.heap.ArenaAllocator.init(alloc); |
| 41 | 45 | while (true) { |
| 42 | 46 | const line = r.readUntilDelimiterAlloc(alloc, '\n', max_size) catch |e| if (e == error.EndOfStream) break else return e; |
| 47 | defer alloc.free(line); |
| 48 | |
| 43 | 49 | if (line.len == 0) { |
| 44 | 50 | continue; |
| 45 | 51 | } |
| ... | ... | @@ -47,7 +53,8 @@ pub fn Main(comptime T: type) type { |
| 47 | 53 | continue; |
| 48 | 54 | } |
| 49 | 55 | |
| 50 | | if (!(try T.exec(alloc, line, w))) { |
| 56 | if (!(try T.exec(&arena.allocator, line, w))) { |
| 57 | arena.deinit(); |
| 51 | 58 | break; |
| 52 | 59 | } |
| 53 | 60 | |