@@ -17,10 +17,11 @@ #include "config.h" #include #import "OFAutoreleasePool.h" +#import "OFAutoreleasePool+Private.h" #import "macros.h" #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) # import "threading.h" @@ -75,10 +76,26 @@ + (id)addObject: (id)object { return _objc_rootAutorelease(object); } + ++ (void)OF_handleThreadTermination +{ +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) + OFAutoreleasePool **cache = of_tlskey_get(cacheKey); +#endif + size_t i; + + if (cache != NULL) { + for (i = 0; i < MAX_CACHE_SIZE; i++) + [cache[i] OF_super_dealloc]; + + free(cache); + cache = NULL; + } +} - init { self = [super init]; @@ -113,10 +130,15 @@ - (void)drain { [self dealloc]; } + +- (void)OF_super_dealloc +{ + [super dealloc]; +} - (void)dealloc { #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OFAutoreleasePool **cache = of_tlskey_get(cacheKey);