authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-21 21:19:01+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-21 21:53:29+02:00
log74bfb8ba07cea0029b86f147834c2b271b38eba7
treeededbb17d12597a632808b28976edc81a5e0dc65
parentbedd7efa2bca82aa1c101ca4144b6bce65c9ab87

pdb: fix resource mgmt


1 files changed, 21 insertions(+), 0 deletions(-)

lib/std/pdb.zig+21
......@@ -498,6 +498,15 @@ pub const Pdb = struct {
498498 symbols: []u8,
499499 subsect_info: []u8,
500500 checksum_offset: ?usize,
501
502 pub fn deinit(self: *Module, allocator: mem.Allocator) void {
503 allocator.free(self.module_name);
504 allocator.free(self.obj_file_name);
505 if (self.populated) {
506 allocator.free(self.symbols);
507 allocator.free(self.subsect_info);
508 }
509 }
501510 };
502511
503512 pub fn init(allocator: mem.Allocator, path: []const u8) !Pdb {
......@@ -519,6 +528,10 @@ pub const Pdb = struct {
519528
520529 pub fn deinit(self: *Pdb) void {
521530 self.in_file.close();
531 self.msf.deinit(self.allocator);
532 for (self.modules) |*module| {
533 module.deinit(self.allocator);
534 }
522535 self.allocator.free(self.modules);
523536 self.allocator.free(self.sect_contribs);
524537 }
......@@ -941,6 +954,14 @@ const Msf = struct {
941954 .streams = streams,
942955 };
943956 }
957
958 fn deinit(self: *Msf, allocator: mem.Allocator) void {
959 allocator.free(self.directory.blocks);
960 for (self.streams) |*stream| {
961 allocator.free(stream.blocks);
962 }
963 allocator.free(self.streams);
964 }
944965};
945966
946967fn blockCountFromSize(size: u32, block_size: u32) u32 {