summaryrefslogtreecommitdiff
path: root/MLKCompiledClosure.m
diff options
context:
space:
mode:
authorMatthias Benkard <mulk@minimulk.mst-plus>2008-09-28 21:28:56 +0200
committerMatthias Benkard <mulk@minimulk.mst-plus>2008-09-28 21:28:56 +0200
commit90a3e20fcfe07c24533cce14e1d1dd8a5d611ed6 (patch)
treea677508c98400fc2d3ea5d06189cca0b3ca1f7f9 /MLKCompiledClosure.m
parent31eed182d7996b7dbc319bd5f2c474a734492b04 (diff)
Use GC-aware allocation instead of malloc(3) where appropriate.
Diffstat (limited to 'MLKCompiledClosure.m')
-rw-r--r--MLKCompiledClosure.m15
1 files changed, 14 insertions, 1 deletions
diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m
index 9227008..6f61b45 100644
--- a/MLKCompiledClosure.m
+++ b/MLKCompiledClosure.m
@@ -26,6 +26,10 @@
#import <Foundation/NSDictionary.h>
#import <Foundation/NSSet.h>
+#ifdef __OBJC_GC__
+#import <Foundation/NSZone.h>
+#endif
+
#import <stdlib.h>
@@ -36,14 +40,23 @@
{
int i;
- _data = data;
_dataLength = dataLength;
_code = code;
+#ifdef __OBJC_GC__
+ _data = NSAllocateCollectable (dataLength * sizeof(id), NSScannedOption);
+ for (i = 0; i < _dataLength; i++)
+ {
+ _data[i] = data[i];
+ }
+ free (data);
+#else
+ _data = data;
for (i = 0; i < _dataLength; i++)
{
LRETAIN (_data[i]);
}
+#endif
return self;
}