stage2: fix memory leak in the cbe

This commit is contained in:
jacob gw 2021-03-01 15:40:48 -05:00 committed by Veikka Tuominen
parent 30ffa052f2
commit d9e46a4b90
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC

View File

@ -92,6 +92,12 @@ pub fn updateDecl(self: *C, module: *Module, decl: *Module.Decl) !void {
const typedefs = &decl.fn_link.c.typedefs;
const code = &decl.link.c.code;
fwd_decl.shrinkRetainingCapacity(0);
{
var it = typedefs.iterator();
while (it.next()) |entry| {
module.gpa.free(entry.value.rendered);
}
}
typedefs.clearRetainingCapacity();
code.shrinkRetainingCapacity(0);