mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-10-08 20:04:02 +00:00
[examples] Fix leaks in OrcV2 c-bindings examples.
rdar://103599609
This commit is contained in:
parent
073cc29e04
commit
23c1822d1a
@ -50,6 +50,9 @@ LLVMModuleRef createDemoModule(LLVMContextRef Ctx) {
|
||||
// - Build the return instruction.
|
||||
LLVMBuildRet(Builder, Result);
|
||||
|
||||
// - Free the builder.
|
||||
LLVMDisposeBuilder(Builder);
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
@ -107,6 +110,12 @@ int main(int argc, char *argv[]) {
|
||||
LLVMContextDispose(Ctx);
|
||||
goto jit_cleanup;
|
||||
}
|
||||
|
||||
// CodeGen succeeded -- We have our module, so free the Module, LLVMContext,
|
||||
// and TargetMachine.
|
||||
LLVMDisposeModule(M);
|
||||
LLVMContextDispose(Ctx);
|
||||
LLVMDisposeTargetMachine(TM);
|
||||
}
|
||||
|
||||
// Add our object file buffer to the JIT.
|
||||
|
@ -55,6 +55,9 @@ LLVMOrcThreadSafeModuleRef createDemoModule(void) {
|
||||
// - Build the return instruction.
|
||||
LLVMBuildRet(Builder, Result);
|
||||
|
||||
// - Free the builder.
|
||||
LLVMDisposeBuilder(Builder);
|
||||
|
||||
// Our demo module is now complete. Wrap it and our ThreadSafeContext in a
|
||||
// ThreadSafeModule.
|
||||
LLVMOrcThreadSafeModuleRef TSM = LLVMOrcCreateNewThreadSafeModule(M, TSCtx);
|
||||
|
@ -100,6 +100,9 @@ LLVMOrcThreadSafeModuleRef createDemoModule(void) {
|
||||
// - Build the return instruction.
|
||||
LLVMBuildRet(Builder, AddResult);
|
||||
|
||||
// - Free the builder.
|
||||
LLVMDisposeBuilder(Builder);
|
||||
|
||||
// Our demo module is now complete. Wrap it and our ThreadSafeContext in a
|
||||
// ThreadSafeModule.
|
||||
LLVMOrcThreadSafeModuleRef TSM = LLVMOrcCreateNewThreadSafeModule(M, TSCtx);
|
||||
|
@ -55,6 +55,9 @@ LLVMOrcThreadSafeModuleRef createDemoModule(void) {
|
||||
// - Build the return instruction.
|
||||
LLVMBuildRet(Builder, Result);
|
||||
|
||||
// - Free the builder.
|
||||
LLVMDisposeBuilder(Builder);
|
||||
|
||||
// Our demo module is now complete. Wrap it and our ThreadSafeContext in a
|
||||
// ThreadSafeModule.
|
||||
LLVMOrcThreadSafeModuleRef TSM = LLVMOrcCreateNewThreadSafeModule(M, TSCtx);
|
||||
|
Loading…
Reference in New Issue
Block a user