summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MLKCompiledClosure.m12
-rw-r--r--MLKLLVMCompiler.mm2
2 files changed, 5 insertions, 9 deletions
diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m
index 6f61b45..fd643e3 100644
--- a/MLKCompiledClosure.m
+++ b/MLKCompiledClosure.m
@@ -45,18 +45,14 @@
#ifdef __OBJC_GC__
_data = NSAllocateCollectable (dataLength * sizeof(id), NSScannedOption);
- for (i = 0; i < _dataLength; i++)
- {
- _data[i] = data[i];
- }
- free (data);
#else
- _data = data;
+ _data = malloc (dataLength * sizeof(id));
+#endif
+
for (i = 0; i < _dataLength; i++)
{
- LRETAIN (_data[i]);
+ _data[i] = LRETAIN (data[i]);
}
-#endif
return self;
}
diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm
index 4a1095e..ae9773b 100644
--- a/MLKLLVMCompiler.mm
+++ b/MLKLLVMCompiler.mm
@@ -615,7 +615,7 @@ static Constant
builder.SetInsertPoint (outerBlock);
NSArray *freeVariables = [[self freeVariables] allObjects];
- Value *closure_data = builder.CreateMalloc (PointerTy,
+ Value *closure_data = builder.CreateAlloca (PointerTy,
ConstantInt::get(Type::Int32Ty,
(uint32_t)[freeVariables count],
false));