diff --git a/src/ripgrep.zig b/src/ripgrep.zig index 6109a92..3d25689 100644 --- a/src/ripgrep.zig +++ b/src/ripgrep.zig @@ -100,10 +100,14 @@ const Process = struct { } fn deinit(self: *Process) void { + if (self.sp) |*sp| sp.deinit(); + self.parent.deinit(); self.output.deinit(); self.logger.deinit(); + self.allocator.free(self.tag); self.allocator.free(self.query); self.close() catch {}; + self.allocator.destroy(self); } fn close(self: *Process) tp.result { @@ -114,6 +118,7 @@ const Process = struct { } fn start(self: *Process) tp.result { + errdefer self.deinit(); _ = tp.set_trap(true); const args = tp.message.fmt(.{ ripgrep_binary, diff --git a/src/tui/filelist_view.zig b/src/tui/filelist_view.zig index cd2a472..8e392cf 100644 --- a/src/tui/filelist_view.zig +++ b/src/tui/filelist_view.zig @@ -67,6 +67,7 @@ pub fn create(allocator: Allocator, parent: Plane) !Widget { } pub fn deinit(self: *Self, allocator: Allocator) void { + self.reset(); self.plane.deinit(); self.commands.deinit(); allocator.destroy(self);