diff options
author | jjanzen <jjanzen@jjanzen.ca> | 2025-01-22 09:49:08 -0600 |
---|---|---|
committer | jjanzen <jjanzen@jjanzen.ca> | 2025-01-22 09:49:08 -0600 |
commit | b7d602f885f992d00ad1ca7d9040782920931293 (patch) | |
tree | 09ffb317cb4c47aa5a8cc0498edf892573ffc2bc /src/main.zig | |
parent | 900c8756edc3bc547dfd2cd47921ecd453bf703b (diff) |
remove generics from io interface
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main.zig b/src/main.zig index 5a6dbb0..6816231 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3,25 +3,35 @@ const IO = @import("frontend/ncurses.zig").IO; const Action = @import("actions.zig").Action; pub fn main() u8 { - var io = IO.init() catch |err| { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + var io = IO.init(allocator) catch |err| { std.log.err("{}", .{err}); return 1; }; defer io.deinit(); - io.displayMessage("Initialized", .{}); + io.displayMessage("Initialized"); var action = Action.illegal; var tick_count: usize = 0; while (action != Action.exit) { - io.displayMessage("{}", .{tick_count}); + var str = std.fmt.allocPrintZ(allocator, "{}", .{tick_count}) catch { + return 1; + }; + io.displayMessage(str); + allocator.free(str); action = io.waitForTick(); switch (action) { Action.tick => { - io.displayMessage("{}", .{tick_count}); + str = std.fmt.allocPrintZ(allocator, "{}", .{tick_count}) catch { + return 1; + }; + io.displayMessage(str); + allocator.free(str); tick_count += 1; }, - else => io.displayMessage("{}", .{tick_count}), + else => {}, } } |