aboutsummaryrefslogtreecommitdiff
path: root/lib/std/pdb.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-04-21 21:19:01 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-04-21 21:53:29 +0200
commit74bfb8ba07cea0029b86f147834c2b271b38eba7 (patch)
treeededbb17d12597a632808b28976edc81a5e0dc65 /lib/std/pdb.zig
parentbedd7efa2bca82aa1c101ca4144b6bce65c9ab87 (diff)
downloadzig-74bfb8ba07cea0029b86f147834c2b271b38eba7.tar.gz
zig-74bfb8ba07cea0029b86f147834c2b271b38eba7.zip
pdb: fix resource mgmt
Diffstat (limited to 'lib/std/pdb.zig')
-rw-r--r--lib/std/pdb.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/std/pdb.zig b/lib/std/pdb.zig
index 88ae849109..46078d6252 100644
--- a/lib/std/pdb.zig
+++ b/lib/std/pdb.zig
@@ -498,6 +498,15 @@ pub const Pdb = struct {
symbols: []u8,
subsect_info: []u8,
checksum_offset: ?usize,
+
+ pub fn deinit(self: *Module, allocator: mem.Allocator) void {
+ allocator.free(self.module_name);
+ allocator.free(self.obj_file_name);
+ if (self.populated) {
+ allocator.free(self.symbols);
+ allocator.free(self.subsect_info);
+ }
+ }
};
pub fn init(allocator: mem.Allocator, path: []const u8) !Pdb {
@@ -519,6 +528,10 @@ pub const Pdb = struct {
pub fn deinit(self: *Pdb) void {
self.in_file.close();
+ self.msf.deinit(self.allocator);
+ for (self.modules) |*module| {
+ module.deinit(self.allocator);
+ }
self.allocator.free(self.modules);
self.allocator.free(self.sect_contribs);
}
@@ -941,6 +954,14 @@ const Msf = struct {
.streams = streams,
};
}
+
+ fn deinit(self: *Msf, allocator: mem.Allocator) void {
+ allocator.free(self.directory.blocks);
+ for (self.streams) |*stream| {
+ allocator.free(stream.blocks);
+ }
+ allocator.free(self.streams);
+ }
};
fn blockCountFromSize(size: u32, block_size: u32) u32 {