diff options
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main.zig b/src/main.zig index 6816231..98f0369 100644 --- a/src/main.zig +++ b/src/main.zig @@ -11,24 +11,28 @@ pub fn main() u8 { }; defer io.deinit(); - io.displayMessage("Initialized"); + try io.displayMessage("Initialized"); var action = Action.illegal; var tick_count: usize = 0; while (action != Action.exit) { - var str = std.fmt.allocPrintZ(allocator, "{}", .{tick_count}) catch { + const str = std.fmt.allocPrint(allocator, "{}", .{tick_count}) catch { + return 1; + }; + defer allocator.free(str); + try io.displayMessage(str); + + action = io.waitForTick() catch { return 1; }; - io.displayMessage(str); - allocator.free(str); - action = io.waitForTick(); switch (action) { Action.tick => { - str = std.fmt.allocPrintZ(allocator, "{}", .{tick_count}) catch { + const str2 = std.fmt.allocPrint(allocator, "{}", .{tick_count}) catch { return 1; }; - io.displayMessage(str); - allocator.free(str); + defer allocator.free(str2); + try io.displayMessage(str2); + tick_count += 1; }, else => {}, |