aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-10-08 08:54:49 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2022-10-25 05:11:28 -0400
commit6a4266d62aacf887a81549d81ae6f312992d2b2c (patch)
treec06696c4224bebe1927779948441aed4f0808b39 /src/Compilation.zig
parent7c9a9a0fd4560d8ce5d61ab96b9403d27dd872b3 (diff)
downloadzig-6a4266d62aacf887a81549d81ae6f312992d2b2c.tar.gz
zig-6a4266d62aacf887a81549d81ae6f312992d2b2c.zip
cbe: fix infinite recursion on recursive types
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index fc71da56f3..99332e5d2b 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -3099,13 +3099,16 @@ fn processOneJob(comp: *Compilation, job: Job) !void {
.decl_index = decl_index,
.decl = decl,
.fwd_decl = fwd_decl.toManaged(gpa),
- .typedefs = c_codegen.TypedefMap.initContext(gpa, .{
- .mod = module,
- }),
+ .typedefs = c_codegen.TypedefMap.initContext(gpa, .{ .mod = module }),
.typedefs_arena = typedefs_arena.allocator(),
};
- defer dg.fwd_decl.deinit();
- defer dg.typedefs.deinit();
+ defer {
+ for (dg.typedefs.values()) |typedef| {
+ module.gpa.free(typedef.rendered);
+ }
+ dg.typedefs.deinit();
+ dg.fwd_decl.deinit();
+ }
c_codegen.genHeader(&dg) catch |err| switch (err) {
error.AnalysisFail => {