chore: improve init/deinit methods

This commit is contained in:
2022-10-21 05:12:56 -03:00
parent 1a56f957c1
commit 4cf58f1faa
11 changed files with 100 additions and 79 deletions

View File

@@ -74,9 +74,10 @@ pub const Backup = struct {
return null;
}
pub fn deinit(self: Self) void {
pub fn deinit(self: *Self) void {
if (self.save_path) |path| self.writeSaveToDisk(self.alloc, path) catch |e| log.err("Failed to write save: {}", .{e});
self.alloc.free(self.buf);
self.* = undefined;
}
fn loadSaveFromDisk(self: *Self, allocator: Allocator, path: []const u8) !void {