do memory freeing for CustomCommands

This commit is contained in:
RadsammyT 2026-02-27 17:10:06 -05:00
commit e5991abe13
No known key found for this signature in database

View file

@ -217,7 +217,18 @@ pub fn main() !void {
CustomCommands.mapping = .init(state.allocator);
var config_parser = try IniParser(Config).init(state.allocator, config_path, migrator.configFieldHandler);
defer config_parser.deinit();
defer CustomCommands.mapping.deinit();
// mapping.deinit() has to be done here
defer {
if (!shutdown or !restart) {
var iter = CustomCommands.mapping.iterator();
while (iter.next()) |i| {
temporary_allocator.free(i.key_ptr.*);
temporary_allocator.free(i.value_ptr.*.cmd);
temporary_allocator.free(i.value_ptr.*.name);
}
CustomCommands.mapping.deinit();
}
}
state.config = config_parser.structure;