From f632ef49a7d5465943ac7ac7c666c0490887caad Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 13 Aug 2008 00:43:48 +0200 Subject: Revert "MLKCompiledClosure: Always indirect through a function pointer before doing a call." This reverts commit dfe50b2e72ddbd0148870748975f00e7fc662314. --- MLKCompiledClosure.h | 3 +-- MLKCompiledClosure.m | 14 +++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/MLKCompiledClosure.h b/MLKCompiledClosure.h index 589c0de..7df6c68 100644 --- a/MLKCompiledClosure.h +++ b/MLKCompiledClosure.h @@ -27,9 +27,8 @@ @interface MLKCompiledClosure : NSObject { int _dataLength; - id (**_code)(); + id (*_code)(); id *_data; - BOOL _ownPointer; // do we own the _code pointer cell? } // Why intptr_t? Because it makes it easier to call this method from diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m index 5dbf6dd..c2ab290 100644 --- a/MLKCompiledClosure.m +++ b/MLKCompiledClosure.m @@ -38,10 +38,7 @@ _data = data; _dataLength = dataLength; - _ownPointer = YES; - - _code = malloc (sizeof (id (*)())); - *_code = code; + _code = code; for (i = 0; i < _dataLength; i++) { @@ -89,7 +86,7 @@ format:@"FFI type is invalid (this is probably a bug)."]; } - ffi_call (&cif, FFI_FN (*_code), &return_value, (void**)argv); + ffi_call (&cif, FFI_FN (_code), &return_value, (void**)argv); // FIXME return [NSArray arrayWithObject:nullify(return_value)]; @@ -111,16 +108,11 @@ [super dealloc]; - // FIXME: Decrease refcount of *_code. Note: When releasing *_code, - // also release _code regardless of whether we own it. - + // FIXME: Decrease refcount of _code. for (i = 0; i < _dataLength; i++) { LRELEASE (_data[i]); } free (_data); - - if (_ownPointer) - free (_code); } @end -- cgit v1.2.3