fix: avoid some potential memory leaks in ripgrep and filelist_view
This commit is contained in:
parent
cfb9f8cf11
commit
9421f4e7f6
2 changed files with 6 additions and 0 deletions
|
@ -100,10 +100,14 @@ const Process = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: *Process) void {
|
fn deinit(self: *Process) void {
|
||||||
|
if (self.sp) |*sp| sp.deinit();
|
||||||
|
self.parent.deinit();
|
||||||
self.output.deinit();
|
self.output.deinit();
|
||||||
self.logger.deinit();
|
self.logger.deinit();
|
||||||
|
self.allocator.free(self.tag);
|
||||||
self.allocator.free(self.query);
|
self.allocator.free(self.query);
|
||||||
self.close() catch {};
|
self.close() catch {};
|
||||||
|
self.allocator.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(self: *Process) tp.result {
|
fn close(self: *Process) tp.result {
|
||||||
|
@ -114,6 +118,7 @@ const Process = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(self: *Process) tp.result {
|
fn start(self: *Process) tp.result {
|
||||||
|
errdefer self.deinit();
|
||||||
_ = tp.set_trap(true);
|
_ = tp.set_trap(true);
|
||||||
const args = tp.message.fmt(.{
|
const args = tp.message.fmt(.{
|
||||||
ripgrep_binary,
|
ripgrep_binary,
|
||||||
|
|
|
@ -67,6 +67,7 @@ pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self, allocator: Allocator) void {
|
pub fn deinit(self: *Self, allocator: Allocator) void {
|
||||||
|
self.reset();
|
||||||
self.plane.deinit();
|
self.plane.deinit();
|
||||||
self.commands.deinit();
|
self.commands.deinit();
|
||||||
allocator.destroy(self);
|
allocator.destroy(self);
|
||||||
|
|
Loading…
Add table
Reference in a new issue