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