Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -119,11 +119,14 @@ ((struct pre_ivar*)instance)->memchunks = NULL; ((struct pre_ivar*)instance)->memchunks_size = 0; ((struct pre_ivar*)instance)->retain_count = 1; #ifndef OF_ATOMIC_OPS - of_spinlock_new(&((struct pre_ivar*)instance)->retain_spinlock); + if (!of_spinlock_new(&((struct pre_ivar*)instance)->retain_spinlock)) { + free(instance); + @throw [OFInitializationFailedException newWithClass: self]; + } #endif instance = (OFObject*)((char*)instance + PRE_IVAR_ALIGN); memset(instance, 0, isize); instance->isa = self; @@ -499,13 +502,13 @@ - retain { #ifdef OF_ATOMIC_OPS of_atomic_inc32(&PRE_IVAR->retain_count); #else - of_spinlock_lock(&PRE_IVAR->retain_spinlock); + assert(of_spinlock_lock(&PRE_IVAR->retain_spinlock)); PRE_IVAR->retain_count++; - of_spinlock_unlock(&PRE_IVAR->retain_spinlock); + assert(of_spinlock_unlock(&PRE_IVAR->retain_spinlock)); #endif return self; } @@ -520,13 +523,13 @@ if (!of_atomic_dec32(&PRE_IVAR->retain_count)) [self dealloc]; #else int32_t c; - of_spinlock_lock(&PRE_IVAR->retain_spinlock); + assert(of_spinlock_lock(&PRE_IVAR->retain_spinlock)); c = --PRE_IVAR->retain_count; - of_spinlock_unlock(&PRE_IVAR->retain_spinlock); + assert(of_spinlock_unlock(&PRE_IVAR->retain_spinlock)); if (!c) [self dealloc]; #endif } Index: src/objc_properties.m ================================================================== --- src/objc_properties.m +++ src/objc_properties.m @@ -8,10 +8,12 @@ * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #include "config.h" + +#include #import #import "OFExceptions.h" @@ -43,16 +45,16 @@ if (atomic) { id *ptr = (id*)((char*)self + offset); #ifdef OF_THREADS unsigned hash = SPINLOCK_HASH(ptr); - of_spinlock_lock(&spinlocks[hash]); + assert(of_spinlock_lock(&spinlocks[hash])); @try { return [[*ptr retain] autorelease]; } @finally { - of_spinlock_unlock(&spinlocks[hash]); + assert(of_spinlock_unlock(&spinlocks[hash])); } #else return [[*ptr retain] autorelease]; #endif } @@ -67,11 +69,11 @@ if (atomic) { id *ptr = (id*)((char*)self + offset); #ifdef OF_THREADS unsigned hash = SPINLOCK_HASH(ptr); - of_spinlock_lock(&spinlocks[hash]); + assert(of_spinlock_lock(&spinlocks[hash])); @try { #endif id old = *ptr; @@ -92,11 +94,11 @@ } [old release]; #ifdef OF_THREADS } @finally { - of_spinlock_unlock(&spinlocks[hash]); + assert(of_spinlock_unlock(&spinlocks[hash])); } #endif return; }