mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
stage2: fix the memory leaks
This commit is contained in:
parent
61b868f9a5
commit
1b702f8ddb
2 changed files with 15 additions and 0 deletions
|
|
@ -2292,6 +2292,20 @@ pub const InnerError = error{ OutOfMemory, AnalysisFail };
|
|||
pub fn deinit(mod: *Module) void {
|
||||
const gpa = mod.gpa;
|
||||
|
||||
// The callsite of `Compilation.create` owns the `root_pkg`, however
|
||||
// Module owns the builtin and std packages that it adds.
|
||||
if (mod.root_pkg.table.remove("builtin")) |entry| {
|
||||
gpa.free(entry.key);
|
||||
entry.value.destroy(gpa);
|
||||
}
|
||||
if (mod.root_pkg.table.remove("std")) |entry| {
|
||||
gpa.free(entry.key);
|
||||
entry.value.destroy(gpa);
|
||||
}
|
||||
if (mod.root_pkg.table.remove("root")) |entry| {
|
||||
gpa.free(entry.key);
|
||||
}
|
||||
|
||||
mod.compile_log_text.deinit(gpa);
|
||||
|
||||
mod.zig_cache_artifact_directory.handle.close();
|
||||
|
|
|
|||
|
|
@ -624,6 +624,7 @@ pub const TestContext = struct {
|
|||
.root_src_path = tmp_src_path,
|
||||
.namespace_hash = Package.root_namespace_hash,
|
||||
};
|
||||
defer root_pkg.table.deinit(allocator);
|
||||
|
||||
const bin_name = try std.zig.binNameAlloc(arena, .{
|
||||
.root_name = "test_case",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue