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...@@ -152,6 +152,10 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
152 return g;152 return g;
153}153}
154154
155void codegen_destroy(CodeGen *codegen) {
156 LLVMDisposeTargetMachine(codegen->target_machine);
157}
158
155void codegen_set_output_h_path(CodeGen *g, Buf *h_path) {159void codegen_set_output_h_path(CodeGen *g, Buf *h_path) {
156 g->out_h_path = h_path;160 g->out_h_path = h_path;
157}161}
src/codegen.hpp+1
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
1616
17CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out_type, BuildMode build_mode,17CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out_type, BuildMode build_mode,
18 Buf *zig_lib_dir);18 Buf *zig_lib_dir);
19void codegen_destroy(CodeGen *codegen);
1920
20void codegen_set_clang_argv(CodeGen *codegen, const char **args, size_t len);21void codegen_set_clang_argv(CodeGen *codegen, const char **args, size_t len);
21void codegen_set_llvm_argv(CodeGen *codegen, const char **args, size_t len);22void 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)...@@ -65,6 +65,8 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path)
65 os_path_join(parent_gen->cache_dir, o_out_name, output_path);65 os_path_join(parent_gen->cache_dir, o_out_name, output_path);
66 codegen_link(child_gen, buf_ptr(output_path));66 codegen_link(child_gen, buf_ptr(output_path));
6767
68 codegen_destroy(child_gen);
69
68 return output_path;70 return output_path;
69}71}
7072
src/main.cpp+1
...@@ -421,6 +421,7 @@ int main(int argc, char **argv) {...@@ -421,6 +421,7 @@ int main(int argc, char **argv) {
421 g->root_package->package_table.put(buf_create_from_str("@build"), build_pkg);421 g->root_package->package_table.put(buf_create_from_str("@build"), build_pkg);
422 codegen_build(g);422 codegen_build(g);
423 codegen_link(g, buf_ptr(path_to_build_exe));423 codegen_link(g, buf_ptr(path_to_build_exe));
424 codegen_destroy(g);
424425
425 Termination term;426 Termination term;
426 os_spawn_process(buf_ptr(path_to_build_exe), args, &term);427 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...@@ -165,7 +165,8 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM
165165
166 MPM.run(*module);166 MPM.run(*module);
167167
168 dest.flush();168 dest.close();
169
169 return false;170 return false;
170}171}
171172