about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-06-04 00:39:22 +0200
committerBaitinq <[email protected]>2025-06-04 00:39:22 +0200
commit1d7383e1fe602abfd04cfdab615fe04de9fb9409 (patch)
tree8358d6e398317d744f240415bcafb368b72f3c01
parentBoostrap: Codegen: Generate object file (diff)
downloadpry-lang-1d7383e1fe602abfd04cfdab615fe04de9fb9409.tar.gz
pry-lang-1d7383e1fe602abfd04cfdab615fe04de9fb9409.tar.bz2
pry-lang-1d7383e1fe602abfd04cfdab615fe04de9fb9409.zip
Bootstrap: Codegen: Fix memory leaks
-rw-r--r--src/bootstrap/codegen.src2
-rw-r--r--src/bootstrap/llvm.src1
2 files changed, 3 insertions, 0 deletions
diff --git a/src/bootstrap/codegen.src b/src/bootstrap/codegen.src
index 43b83e1..db18380 100644
--- a/src/bootstrap/codegen.src
+++ b/src/bootstrap/codegen.src
@@ -54,6 +54,7 @@ let codegen_compile = (c: *codegen) => i64 {
             LLVMRelocDefault,
             LLVMCodeModelDefault,
         );
+        LLVMDisposeMessage(triple);
         result = LLVMVerifyModule((*c).llvm_module, LLVMAbortProcessAction, message);
         if result != 0 {
             println("Verification output: %s", *message);
@@ -69,6 +70,7 @@ let codegen_compile = (c: *codegen) => i64 {
             LLVMObjectFile,
             cast(**i8, null),
         );
+        LLVMDisposeTargetMachine(target_machine);
         println("Object file generated: %s", filename);
 
 	return 0;
diff --git a/src/bootstrap/llvm.src b/src/bootstrap/llvm.src
index 4a9c349..4dead44 100644
--- a/src/bootstrap/llvm.src
+++ b/src/bootstrap/llvm.src
@@ -16,6 +16,7 @@ extern LLVMGetDefaultTargetTriple = () => *i8;
 extern LLVMGetTargetFromTriple = (*i8, **void, **i8) => i64;
 extern LLVMDisposeMessage = (*i8) => void;
 extern LLVMCreateTargetMachine = (*void, *i8, *i8, *i8, i64, i64, i64) => *void;
+extern LLVMDisposeTargetMachine = (*void) => void;
 
 let LLVMCodeGenLevelDefault = 2;
 let LLVMRelocDefault = 0;