@@ -49,16 +49,16 @@ memchunks_size = __memchunks_size + 1; if (SIZE_MAX - __memchunks_size == 0 || memchunks_size > SIZE_MAX / sizeof(void*)) - @throw [OFOutOfRangeException newWithObject: self]; + @throw [OFOutOfRangeException newWithClass: [self class]]; if ((memchunks = realloc(__memchunks, memchunks_size * sizeof(void*))) == NULL) - @throw [OFNoMemException newWithObject: self - andSize: memchunks_size]; + @throw [OFNoMemException newWithClass: [self class] + andSize: memchunks_size]; __memchunks = memchunks; __memchunks[__memchunks_size] = ptr; __memchunks_size = memchunks_size; @@ -75,21 +75,21 @@ memchunks_size = __memchunks_size + 1; if (SIZE_MAX - __memchunks_size == 0 || memchunks_size > SIZE_MAX / sizeof(void*)) - @throw [OFOutOfRangeException newWithObject: self]; + @throw [OFOutOfRangeException newWithClass: [self class]]; + + if ((ptr = malloc(size)) == NULL) + @throw [OFNoMemException newWithClass: [self class] + andSize: size]; if ((memchunks = realloc(__memchunks, - memchunks_size * sizeof(void*))) == NULL) - @throw [OFNoMemException newWithObject: self - andSize: memchunks_size]; - - if ((ptr = malloc(size)) == NULL) { - free(memchunks); - @throw [OFNoMemException newWithObject: self - andSize: size]; + memchunks_size * sizeof(void*))) == NULL) { + free(ptr); + @throw [OFNoMemException newWithClass: [self class] + andSize: memchunks_size]; } __memchunks = memchunks; __memchunks[__memchunks_size] = ptr; __memchunks_size = memchunks_size; @@ -102,11 +102,11 @@ { if (nitems == 0 || size == 0) return NULL; if (nitems > SIZE_MAX / size) - @throw [OFOutOfRangeException newWithObject: self]; + @throw [OFOutOfRangeException newWithClass: [self class]]; return [self getMemWithSize: nitems * size]; } - (void*)resizeMem: (void*)ptr @@ -125,20 +125,21 @@ iter = __memchunks + __memchunks_size; while (iter-- > __memchunks) { if (OF_UNLIKELY(*iter == ptr)) { if (OF_UNLIKELY((ptr = realloc(ptr, size)) == NULL)) - @throw [OFNoMemException newWithObject: self - andSize: size]; + @throw [OFNoMemException + newWithClass: [self class] + andSize: size]; *iter = ptr; return ptr; } } - @throw [OFMemNotPartOfObjException newWithObject: self - andPointer: ptr]; + @throw [OFMemNotPartOfObjException newWithClass: [self class] + andPointer: ptr]; return NULL; /* never reached, but makes gcc happy */ } - (void*)resizeMem: (void*)ptr toNItems: (size_t)nitems @@ -154,11 +155,11 @@ [self freeMem: ptr]; return NULL; } if (nitems > SIZE_MAX / size) - @throw [OFOutOfRangeException newWithObject: self]; + @throw [OFOutOfRangeException newWithClass: [self class]]; memsize = nitems * size; return [self resizeMem: ptr toSize: memsize]; } @@ -179,11 +180,11 @@ last = __memchunks[memchunks_size]; if (OF_UNLIKELY(__memchunks_size == 0 || memchunks_size > SIZE_MAX / sizeof(void*))) @throw [OFOutOfRangeException - newWithObject: self]; + newWithClass: [self class]]; if (OF_UNLIKELY(memchunks_size == 0)) { free(ptr); free(__memchunks); @@ -194,12 +195,12 @@ } if (OF_UNLIKELY((memchunks = realloc(__memchunks, memchunks_size * sizeof(void*))) == NULL)) @throw [OFNoMemException - newWithObject: self - andSize: memchunks_size]; + newWithClass: [self class] + andSize: memchunks_size]; free(ptr); __memchunks = memchunks; __memchunks[i] = last; __memchunks_size = memchunks_size; @@ -206,10 +207,10 @@ return self; } } - @throw [OFMemNotPartOfObjException newWithObject: self - andPointer: ptr]; + @throw [OFMemNotPartOfObjException newWithClass: [self class] + andPointer: ptr]; return self; /* never reached, but makes gcc happy */ } @end