@@ -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