diff options
author | Matthias Benkard <mulk@minimulk.mst-plus> | 2008-09-28 21:28:56 +0200 |
---|---|---|
committer | Matthias Benkard <mulk@minimulk.mst-plus> | 2008-09-28 21:28:56 +0200 |
commit | 90a3e20fcfe07c24533cce14e1d1dd8a5d611ed6 (patch) | |
tree | a677508c98400fc2d3ea5d06189cca0b3ca1f7f9 | |
parent | 31eed182d7996b7dbc319bd5f2c474a734492b04 (diff) |
Use GC-aware allocation instead of malloc(3) where appropriate.
-rw-r--r-- | MLKBinaryStreamCharacterStream.m | 2 | ||||
-rw-r--r-- | MLKCompiledClosure.m | 15 | ||||
-rw-r--r-- | MLKForeignProcedure.h | 1 | ||||
-rw-r--r-- | MLKForeignProcedure.m | 14 | ||||
-rw-r--r-- | MLKForm.m | 10 |
5 files changed, 33 insertions, 9 deletions
diff --git a/MLKBinaryStreamCharacterStream.m b/MLKBinaryStreamCharacterStream.m index 6fc7119..4efe6e7 100644 --- a/MLKBinaryStreamCharacterStream.m +++ b/MLKBinaryStreamCharacterStream.m @@ -66,7 +66,7 @@ { retval = [tmpstr characterAtIndex:0]; [tmpstr release]; - //free (buffer); + //FIXME: ? free (buffer); return retval; } else 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; } diff --git a/MLKForeignProcedure.h b/MLKForeignProcedure.h index 160bb7c..cb63d32 100644 --- a/MLKForeignProcedure.h +++ b/MLKForeignProcedure.h @@ -43,5 +43,4 @@ -(NSString *) descriptionForLisp; -(void) dealloc; --(void) finalize; @end diff --git a/MLKForeignProcedure.m b/MLKForeignProcedure.m index ce4ac8a..f268005 100644 --- a/MLKForeignProcedure.m +++ b/MLKForeignProcedure.m @@ -23,6 +23,10 @@ #import <Foundation/NSArray.h> #import <Foundation/NSEnumerator.h> +#ifdef __OBJC_GC__ +#import <Foundation/NSZone.h> +#endif + #ifdef HAVE_FFI_H #include <ffi.h> #elif HAVE_FFI_FFI_H @@ -47,7 +51,11 @@ _code = code; _returnType = returnType; +#ifdef __OBJC_GC__ + _argumentTypes = NSAllocateCollectable (sizeof (MLKForeignType) * [argTypes count], NSScannedOption); +#else _argumentTypes = malloc (sizeof (MLKForeignType) * [argTypes count]); +#endif e = [argTypes objectEnumerator]; i = 0; @@ -113,10 +121,4 @@ free (_argumentTypes); [super dealloc]; } - --(void) finalize -{ - free (_argumentTypes); - [super finalize]; -} @end @@ -26,6 +26,10 @@ #import <Foundation/NSSet.h> #import <Foundation/NSString.h> +#ifdef __OBJC_GC__ +#import <Foundation/NSZone.h> +#endif + #include <stdlib.h> #define MAKE_FORM(OBJECT) \ @@ -489,7 +493,13 @@ argtypes = [[[_tail cdr] cdr] car]; _argc = [argtypes length]; + +#ifdef __OBJC_GC__ + _argumentTypes = NSAllocateCollectable (_argc * sizeof (MLKForeignType), NSScannedOption); +#else _argumentTypes = malloc (_argc * sizeof (MLKForeignType)); +#endif + while (argtypes) { _argumentTypes[i] = MLKForeignTypeWithTypeDesignator ([argtypes car]); |