Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -50,12 +50,11 @@ } - (void*)item: (size_t)item { if (item >= items) - /* FIXME: Maybe OFOutOfRangeException would be better? */ - [[OFOverflowException newWithObject: self] raise]; + [[OFOutOfRangeException newWithObject: self] raise]; return data + item * itemsize; } - (void*)last @@ -76,11 +75,11 @@ - addNItems: (size_t)nitems fromCArray: (void*)carray { if (nitems > SIZE_MAX - items) - [[OFOverflowException newWithObject: self] raise]; + [[OFOutOfRangeException newWithObject: self] raise]; data = [self resizeMem: data toNItems: items + nitems ofSize: itemsize]; @@ -91,11 +90,11 @@ } - removeNItems: (size_t)nitems { if (nitems > items) - [[OFOverflowException newWithObject: self] raise]; + [[OFOutOfRangeException newWithObject: self] raise]; data = [self resizeMem: data toNItems: items - nitems ofSize: itemsize]; Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -64,11 +64,11 @@ andPointer: (void*)ptr; - (char*)cString; - (void*)pointer; @end -@interface OFOverflowException: OFException +@interface OFOutOfRangeException: OFException + newWithObject: (id)obj; - initWithObject: (id)obj; @end @interface OFOpenFileFailedException: OFException Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -168,14 +168,14 @@ { return pointer; } @end -@implementation OFOverflowException +@implementation OFOutOfRangeException + newWithObject: (id)obj { - return [[OFOverflowException alloc] initWithObject: obj]; + return [[OFOutOfRangeException alloc] initWithObject: obj]; } - initWithObject: (id)obj { return (self = [super initWithObject: obj]); @@ -184,11 +184,11 @@ - (char*)cString { if (string != NULL) return string; - asprintf(&string, "ERROR: Overflow in object of class %s!\n", + asprintf(&string, "ERROR: Value out of range in object of class %s!\n", object != nil ? [object name] : "(null)"); return string; } @end Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -83,11 +83,11 @@ if (nitems == 0 || size == 0) return NULL; if (size > SIZE_MAX / nitems) - [[OFOverflowException newWithObject: self] raise]; + [[OFOutOfRangeException newWithObject: self] raise]; memsize = nitems * size; return [self getMemWithSize: memsize]; } @@ -134,11 +134,11 @@ [self freeMem: ptr]; return NULL; } if (size > SIZE_MAX / nitems) - [[OFOverflowException newWithObject: self] raise]; + [[OFOutOfRangeException newWithObject: self] raise]; memsize = nitems * size; return [self resizeMem: ptr toSize: memsize]; } Index: tests/OFArray/OFArray.m ================================================================== --- tests/OFArray/OFArray.m +++ tests/OFArray/OFArray.m @@ -43,11 +43,11 @@ puts("Trying to add too much to an array..."); a = [OFArray newWithItemSize: 4096]; CATCH_EXCEPTION([a addNItems: SIZE_MAX fromCArray: NULL], - OFOverflowException) + OFOutOfRangeException) puts("Trying to add something after that error..."); p = [a getMemWithSize: 4096]; memset(p, 255, 4096); [a add: p]; @@ -92,14 +92,14 @@ puts("[a items] + 2 != i!"); abort(); } puts("Trying to remove more data than we added..."); - CATCH_EXCEPTION([a removeNItems: [a items] + 1], OFOverflowException); + CATCH_EXCEPTION([a removeNItems: [a items] + 1], OFOutOfRangeException); puts("Trying to access an index that does not exist..."); - CATCH_EXCEPTION([a item: [a items]], OFOverflowException); + CATCH_EXCEPTION([a item: [a items]], OFOutOfRangeException); [a free]; puts("Creating new array and using it to build a string..."); a = [OFArray newWithItemSize: 1];