authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-15 21:06:04-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-15 21:06:04-04:00
log562f91e875e870eb9f2948dd4de607441f5a6be9
treebb1860a238106bade81cfdde40cea637680caec2
parente3ad13e05425b3afc9dbac19438ee8a978dcd1e8

clean up some resources


5 files changed, 10 insertions(+), 1 deletions(-)

src/codegen.cpp+4
......@@ -152,6 +152,10 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
152152 return g;
153153}
154154
155void codegen_destroy(CodeGen *codegen) {
156 LLVMDisposeTargetMachine(codegen->target_machine);
157}
158
155159void codegen_set_output_h_path(CodeGen *g, Buf *h_path) {
156160 g->out_h_path = h_path;
157161}
src/codegen.hpp+1
......@@ -16,6 +16,7 @@
1616
1717CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out_type, BuildMode build_mode,
1818 Buf *zig_lib_dir);
19void codegen_destroy(CodeGen *codegen);
1920
2021void codegen_set_clang_argv(CodeGen *codegen, const char **args, size_t len);
2122void codegen_set_llvm_argv(CodeGen *codegen, const char **args, size_t len);
src/link.cpp+2
......@@ -65,6 +65,8 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path)
6565 os_path_join(parent_gen->cache_dir, o_out_name, output_path);
6666 codegen_link(child_gen, buf_ptr(output_path));
6767
68 codegen_destroy(child_gen);
69
6870 return output_path;
6971}
7072
src/main.cpp+1
......@@ -421,6 +421,7 @@ int main(int argc, char **argv) {
421421 g->root_package->package_table.put(buf_create_from_str("@build"), build_pkg);
422422 codegen_build(g);
423423 codegen_link(g, buf_ptr(path_to_build_exe));
424 codegen_destroy(g);
424425
425426 Termination term;
426427 os_spawn_process(buf_ptr(path_to_build_exe), args, &term);
src/zig_llvm.cpp+2-1
......@@ -165,7 +165,8 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM
165165
166166 MPM.run(*module);
167167
168 dest.flush();
168 dest.close();
169
169170 return false;
170171}
171172