@@ -33,10 +33,14 @@ /* Hopefully no arch needs more than 16 bytes padding */ #define PRE_IVAR_ALIGN ((sizeof(struct pre_ivar) + 15) & ~15) #define PRE_IVAR ((struct pre_ivar*)((char*)self - PRE_IVAR_ALIGN)) +static struct { + Class isa; +} alloc_failed_exception; + @implementation OFObject #ifndef __objc_INCLUDE_GNU + load { return self; @@ -55,12 +59,14 @@ size_t isize = class_get_instance_size(self); #else size_t isize = class_getInstanceSize(self); #endif - if ((instance = malloc(isize + PRE_IVAR_ALIGN)) == NULL) - return nil; + if ((instance = malloc(isize + PRE_IVAR_ALIGN)) == NULL) { + alloc_failed_exception.isa = [OFAllocFailedException class]; + @throw (OFAllocFailedException*)&alloc_failed_exception; + } ((struct pre_ivar*)instance)->memchunks = NULL; ((struct pre_ivar*)instance)->memchunks_size = 0; ((struct pre_ivar*)instance)->retain_count = 1;