Index: src/OFAutoreleasePool.h ================================================================== --- src/OFAutoreleasePool.h +++ src/OFAutoreleasePool.h @@ -66,5 +66,13 @@ /** * \brief Releases all objects in the autorelease pool and deallocates the pool. */ - (void)drain; @end + +#ifdef __cplusplus +extern "C" { +#endif +extern id of_autorelease(id); +#ifdef __cplusplus +} +#endif Index: src/OFAutoreleasePool.m ================================================================== --- src/OFAutoreleasePool.m +++ src/OFAutoreleasePool.m @@ -38,10 +38,23 @@ static __thread void *first = NULL; static __thread OFAutoreleasePool **cache = NULL; #else static of_tlskey_t firstKey, cacheKey; #endif + +id +of_autorelease(id object) +{ +#ifndef OF_COMPILER_TLS + void *first = of_tlskey_get(firstKey); +#endif + + if (first == NULL) + [[OFAutoreleasePool alloc] init]; + + return _objc_rootAutorelease(object); +} @implementation OFAutoreleasePool #ifndef OF_COMPILER_TLS + (void)initialize { @@ -75,18 +88,11 @@ return [super alloc]; } + (id)addObject: (id)object { -#ifndef OF_COMPILER_TLS - void *first = of_tlskey_get(firstKey); -#endif - - if (first == NULL) - [[OFAutoreleasePool alloc] init]; - - return _objc_rootAutorelease(object); + return of_autorelease(object); } + (void)OF_releaseAll { #ifndef OF_COMPILER_TLS Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -32,10 +32,11 @@ #import "OFObject.h" #import "OFTimer.h" #import "OFThread.h" #import "OFRunLoop.h" +#import "OFAutoreleasePool.h" #import "OFAllocFailedException.h" #import "OFEnumerationMutationException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" @@ -569,17 +570,17 @@ return imp(self, selector, object); } - (id)performSelector: (SEL)selector - withObject: (id)object - withObject: (id)otherObject + withObject: (id)object1 + withObject: (id)object2 { id (*imp)(id, SEL, id, id) = (id(*)(id, SEL, id, id))[self methodForSelector: selector]; - return imp(self, selector, object, otherObject); + return imp(self, selector, object1, object2); } - (void)performSelector: (SEL)selector afterDelay: (double)delay { @@ -883,11 +884,11 @@ #endif } - autorelease { - return _objc_rootAutorelease(self); + return of_autorelease(self); } - self { return self;