properly fix memleaks

This commit is contained in:
Luna 2022-04-28 00:28:07 -03:00
parent 2796b654e5
commit 6b2ce7e425

View file

@ -479,26 +479,25 @@ pub const CommandList = struct {
pub fn deinit(self: *Self) void { pub fn deinit(self: *Self) void {
for (self.list.items) |cmd_ptr| { for (self.list.items) |cmd_ptr| {
//self.list.allocator.destroy(cmd_ptr);
inline for (@typeInfo(Command.Tag).Enum.fields) |field| { inline for (@typeInfo(Command.Tag).Enum.fields) |field| {
if (cmd_ptr.tag == @field(Command.Tag, field.name)) { if (cmd_ptr.tag == @field(Command.Tag, field.name)) {
const actual_tag = const actual_tag =
@field(Command.Tag, field.name); @field(Command.Tag, field.name);
// if we find a match on the tag, we can get the type // if we find a match on the tag, we can get the type
const typ = Command.tagToType(actual_tag); const typ = Command.tagToType(actual_tag);
_ = typ;
// TODO fix const inner_command = cmd_ptr.cast(typ).?;
inline for (@typeInfo(typ).Struct.fields) |cmd_field| {
//inline for (@typeInfo(typ).Struct.fields) |cmd_field| { switch (cmd_field.field_type) {
// switch (cmd_field.field_type) { []u8, []const u8 => self.list.allocator.free(@field(inner_command, cmd_field.name)),
// []u8, []const u8 => self.list.allocator.destroy(@field(typ, cmd_field.name)), else => {},
// else => {},
// }
//}
} }
} }
} }
}
self.list.allocator.destroy(cmd_ptr);
}
self.list.deinit(); self.list.deinit();
} }