@@ -133,19 +133,26 @@ of_thread_exit(); } - init { - @throw [OFNotImplementedException newWithClass: isa + Class c = isa; + [self release]; + @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithObject: (id)obj { self = [super init]; - object = [obj retain]; + @try { + object = [obj retain]; + } @catch (id e) { + [self release]; + @throw e; + } return self; } - (id)main @@ -227,31 +234,23 @@ - init { self = [super init]; - if (!of_tlskey_new(&key)) { - Class c = isa; - [super dealloc]; - @throw [OFInitializationFailedException newWithClass: c]; - } - - destructor = NULL; - - @synchronized (tlskeys) { - @try { + @try { + if (!of_tlskey_new(&key)) + @throw [OFInitializationFailedException + newWithClass: isa]; + + destructor = NULL; + + @synchronized (tlskeys) { listobj = [tlskeys appendObject: self]; - } @catch (OFException *e) { - /* - * We can't use [super dealloc] on OS X here. - * Compiler bug? Anyway, [self dealloc] will do here - * as we check listobj != NULL in dealloc. - */ - listobj = NULL; - [self dealloc]; - @throw e; - } + } + } @catch (id e) { + [self release]; + @throw e; } return self; } @@ -269,14 +268,15 @@ if (destructor != NULL) destructor(self); of_tlskey_free(key); - @synchronized (tlskeys) { - /* In case we called [self dealloc] in init */ - if (listobj != NULL) + /* In case we called [self release] in init */ + if (listobj != NULL) { + @synchronized (tlskeys) { [tlskeys removeListObject: listobj]; + } } [super dealloc]; } @end @@ -291,11 +291,11 @@ { self = [super init]; if (!of_mutex_new(&mutex)) { Class c = isa; - [self dealloc]; + [self release]; @throw [OFInitializationFailedException newWithClass: c]; } return self; }