@@ -18,31 +18,19 @@ #import "OFThread.h" #import "OFExceptions.h" #import "threading.h" -/* - * Pay special attention to NULL and nil in this file, they might be different! - * Use NULL for TLS values and nil for instance variables. - */ - static of_tlskey_t first_key, last_key; -static void -release_all(id obj) -{ - [of_tlskey_get(first_key) release]; -} - @implementation OFAutoreleasePool + (void)initialize { if (self != [OFAutoreleasePool class]) return; - if (!of_tlskey_new(&first_key, release_all) || - !of_tlskey_new(&last_key, NULL)) + if (!of_tlskey_new(&first_key) || !of_tlskey_new(&last_key)) @throw [OFInitializationFailedException newWithClass: self]; } + (void)addObjectToTopmostPool: (OFObject*)obj { @@ -69,10 +57,15 @@ } @catch (OFException *e) { [obj release]; @throw e; } } + ++ (void)releaseAll +{ + [of_tlskey_get(first_key) release]; +} - init { id first;