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 {...@@ -498,6 +498,15 @@ pub const Pdb = struct {
498 symbols: []u8,498 symbols: []u8,
499 subsect_info: []u8,499 subsect_info: []u8,
500 checksum_offset: ?usize,500 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 }
501 };510 };
502511
503 pub fn init(allocator: mem.Allocator, path: []const u8) !Pdb {512 pub fn init(allocator: mem.Allocator, path: []const u8) !Pdb {
...@@ -519,6 +528,10 @@ pub const Pdb = struct {...@@ -519,6 +528,10 @@ pub const Pdb = struct {
519528
520 pub fn deinit(self: *Pdb) void {529 pub fn deinit(self: *Pdb) void {
521 self.in_file.close();530 self.in_file.close();
531 self.msf.deinit(self.allocator);
532 for (self.modules) |*module| {
533 module.deinit(self.allocator);
534 }
522 self.allocator.free(self.modules);535 self.allocator.free(self.modules);
523 self.allocator.free(self.sect_contribs);536 self.allocator.free(self.sect_contribs);
524 }537 }
...@@ -941,6 +954,14 @@ const Msf = struct {...@@ -941,6 +954,14 @@ const Msf = struct {
941 .streams = streams,954 .streams = streams,
942 };955 };
943 }956 }
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 }
944};965};
945966
946fn blockCountFromSize(size: u32, block_size: u32) u32 {967fn blockCountFromSize(size: u32, block_size: u32) u32 {