Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -244,12 +244,12 @@ size_t count; id *buffer; container = [[[OFObject alloc] init] autorelease]; count = [self count]; - buffer = [container allocMemoryWithItemSize: sizeof(*buffer) - count: [self count]]; + buffer = [container allocMemoryWithSize: sizeof(*buffer) + count: [self count]]; [self getObjects: buffer inRange: of_range(0, count)]; return buffer; @@ -333,12 +333,12 @@ if (![self isKindOfClass: [OFMutableArray class]]) return [OFArray_subarray arrayWithArray: self range: range]; - buffer = [self allocMemoryWithItemSize: sizeof(*buffer) - count: range.length]; + buffer = [self allocMemoryWithSize: sizeof(*buffer) + count: range.length]; @try { [self getObjects: buffer inRange: range]; @@ -607,12 +607,12 @@ #ifdef OF_HAVE_BLOCKS - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; size_t count = [self count]; - id *tmp = [self allocMemoryWithItemSize: sizeof(id) - count: count]; + id *tmp = [self allocMemoryWithSize: sizeof(id) + count: count]; @try { [self enumerateObjectsUsingBlock: ^ (id object, size_t index, BOOL *stop) { tmp[index] = block(object, index); @@ -629,12 +629,12 @@ - (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block { OFArray *ret; size_t count = [self count]; - id *tmp = [self allocMemoryWithItemSize: sizeof(id) - count: count]; + id *tmp = [self allocMemoryWithSize: sizeof(id) + count: count]; @try { __block size_t i = 0; [self enumerateObjectsUsingBlock: ^ (id object, size_t index, Index: src/OFAutoreleasePool.m ================================================================== --- src/OFAutoreleasePool.m +++ src/OFAutoreleasePool.m @@ -119,12 +119,12 @@ if (previousPool != nil) previousPool->nextPool = self; size = GROW_SIZE; - objects = [self allocMemoryWithItemSize: sizeof(id) - count: GROW_SIZE]; + objects = [self allocMemoryWithSize: sizeof(id) + count: GROW_SIZE]; } @catch (id e) { [self release]; @throw e; } @@ -133,11 +133,11 @@ - (void)_addObject: (id)object { if (count + 1 > size) { objects = [self resizeMemory: objects - itemSize: sizeof(id) + size: sizeof(id) count: size + GROW_SIZE]; size += GROW_SIZE; } objects[count] = object; Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -402,27 +402,27 @@ { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } -- (void*)allocMemoryForNItems: (size_t)nitems - withSize: (size_t)size +- (void*)allocMemoryWithSize: (size_t)size + count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - (void*)resizeMemory: (void*)ptr - toSize: (size_t)size + size: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - (void*)resizeMemory: (void*)ptr - toNItems: (size_t)nitems - withSize: (size_t)size + size: (size_t)size + count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -60,19 +60,19 @@ { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } -- (void*)allocMemoryForNItems: (size_t)nitems - withSize: (size_t)size +- (void*)allocMemoryWithSize: (size_t)itemSize + count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - (void*)resizeMemory: (void*)ptr - toSize: (size_t)size + size: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } @@ -180,27 +180,27 @@ { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } -- (void*)allocMemoryForNItems: (size_t)nitems - withSize: (size_t)size +- (void*)allocMemoryWithSize: (size_t)size + count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - (void*)resizeMemory: (void*)ptr - toSize: (size_t)size + size: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - (void*)resizeMemory: (void*)ptr - toNItems: (size_t)nitems - withSize: (size_t)size + size: (size_t)size + count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -255,11 +255,11 @@ { if (SIZE_MAX - count < 1) @throw [OFOutOfRangeException exceptionWithClass: isa]; data = [self resizeMemory: data - itemSize: itemSize + size: itemSize count: count + 1]; memcpy(data + count * itemSize, item, itemSize); count++; @@ -278,11 +278,11 @@ { if (nItems > SIZE_MAX - count) @throw [OFOutOfRangeException exceptionWithClass: isa]; data = [self resizeMemory: data - itemSize: itemSize + size: itemSize count: count + nItems]; memcpy(data + count * itemSize, cArray, nItems * itemSize); count += nItems; } @@ -293,11 +293,11 @@ { if (nItems > SIZE_MAX - count || index > count) @throw [OFOutOfRangeException exceptionWithClass: isa]; data = [self resizeMemory: data - itemSize: itemSize + size: itemSize count: count + nItems]; memmove(data + (index + nItems) * itemSize, data + index * itemSize, (count - index) * itemSize); memcpy(data + index * itemSize, cArray, nItems * itemSize); @@ -320,11 +320,11 @@ (count - range.start - range.length) * itemSize); count -= range.length; @try { data = [self resizeMemory: data - itemSize: itemSize + size: itemSize count: count]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } @@ -335,11 +335,11 @@ @throw [OFOutOfRangeException exceptionWithClass: isa]; count--; @try { data = [self resizeMemory: data - itemSize: itemSize + size: itemSize count: count]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only made it smaller */ } } @@ -478,11 +478,11 @@ lastPageByte = of_pagesize - 1; newSize = ((count + 1) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) data = [self resizeMemory: data - toSize: newSize]; + size: newSize]; memcpy(data + count * itemSize, item, itemSize); count++; size = newSize; @@ -499,11 +499,11 @@ lastPageByte = of_pagesize - 1; newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) data = [self resizeMemory: data - toSize: newSize]; + size: newSize]; memcpy(data + count * itemSize, cArray, nItems * itemSize); count += nItems; size = newSize; @@ -522,11 +522,11 @@ lastPageByte = of_pagesize - 1; newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) data = [self resizeMemory: data - toSize: newSize]; + size: newSize]; memmove(data + (index + nItems) * itemSize, data + index * itemSize, (count - index) * itemSize); memcpy(data + index * itemSize, cArray, nItems * itemSize); @@ -549,11 +549,11 @@ lastPageByte = of_pagesize - 1; newSize = (count * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) data = [self resizeMemory: data - toSize: newSize]; + size: newSize]; size = newSize; } - (void)removeLastItem { @@ -567,11 +567,11 @@ newSize = (count * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) { @try { data = [self resizeMemory: data - toSize: newSize]; + size: newSize]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only made it smaller */ } size = newSize; Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -350,12 +350,12 @@ } - (OFArray*)allKeys { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - id *keys = [self allocMemoryWithItemSize: sizeof(id) - count: [self count]]; + id *keys = [self allocMemoryWithSize: sizeof(id) + count: [self count]]; OFArray *ret; OFEnumerator *enumerator; id key; size_t i = 0; @@ -380,12 +380,12 @@ } - (OFArray*)allObjects { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - id *objects = [self allocMemoryWithItemSize: sizeof(id) - count: [self count]]; + id *objects = [self allocMemoryWithSize: sizeof(id) + count: [self count]]; OFArray *ret; OFEnumerator *enumerator; id object; size_t i = 0; Index: src/OFDictionary_hashtable.m ================================================================== --- src/OFDictionary_hashtable.m +++ src/OFDictionary_hashtable.m @@ -79,12 +79,12 @@ exceptionWithClass: isa selector: _cmd]; hashtable = (OFDictionary_hashtable*)dictionary; - data = [self allocMemoryWithItemSize: sizeof(*data) - count: hashtable->size]; + data = [self allocMemoryWithSize: sizeof(*data) + count: hashtable->size]; for (i = 0; i < hashtable->size; i++) data[i] = NULL; size = hashtable->size; @@ -139,12 +139,12 @@ newSize <<= 1; if (newSize == 0) @throw [OFOutOfRangeException exceptionWithClass: isa]; - data = [self allocMemoryWithItemSize: sizeof(*data) - count: newSize]; + data = [self allocMemoryWithSize: sizeof(*data) + count: newSize]; for (i = 0; i < newSize; i++) data[i] = NULL; size = newSize; @@ -206,12 +206,12 @@ if (key == nil || object == nil) @throw [OFInvalidArgumentException exceptionWithClass: isa selector: _cmd]; - data = [self allocMemoryWithItemSize: sizeof(*data) - count: 2]; + data = [self allocMemoryWithSize: sizeof(*data) + count: 2]; size = 2; for (i = 0; i < size; i++) data[i] = NULL; @@ -272,12 +272,12 @@ newSize <<= 1; if (newSize == 0) @throw [OFOutOfRangeException exceptionWithClass: isa]; - data = [self allocMemoryWithItemSize: sizeof(*data) - count: newSize]; + data = [self allocMemoryWithSize: sizeof(*data) + count: newSize]; for (j = 0; j < newSize; j++) data[j] = NULL; size = newSize; @@ -393,12 +393,12 @@ newSize <<= 1; if (newSize == 0) @throw [OFOutOfRangeException exceptionWithClass: isa]; - data = [self allocMemoryWithItemSize: sizeof(*data) - count: newSize]; + data = [self allocMemoryWithSize: sizeof(*data) + count: newSize]; for (j = 0; j < newSize; j++) data[j] = NULL; size = newSize; @@ -646,12 +646,12 @@ } - (OFArray*)allKeys { OFArray *ret; - id *keys = [self allocMemoryWithItemSize: sizeof(*keys) - count: count]; + id *keys = [self allocMemoryWithSize: sizeof(*keys) + count: count]; size_t i, j; for (i = j = 0; i < size; i++) if (data[i] != NULL && data[i] != DELETED) keys[j++] = data[i]->key; @@ -669,12 +669,12 @@ } - (OFArray*)allObjects { OFArray *ret; - id *objects = [self allocMemoryWithItemSize: sizeof(*objects) - count: count]; + id *objects = [self allocMemoryWithSize: sizeof(*objects) + count: count]; size_t i, j; for (i = j = 0; i < size; i++) if (data[i] != NULL && data[i] != DELETED) objects[j++] = data[i]->object; Index: src/OFMutableArray_adjacent.m ================================================================== --- src/OFMutableArray_adjacent.m +++ src/OFMutableArray_adjacent.m @@ -162,12 +162,12 @@ size_t i, count = [array count]; if (range.length > count - range.start) @throw [OFOutOfRangeException exceptionWithClass: isa]; - copy = [self allocMemoryWithItemSize: sizeof(*copy) - count: range.length]; + copy = [self allocMemoryWithSize: sizeof(*copy) + count: range.length]; memcpy(copy, objects + range.start, range.length * sizeof(id)); @try { [array removeItemsInRange: range]; mutations++; Index: src/OFMutableDictionary_hashtable.m ================================================================== --- src/OFMutableDictionary_hashtable.m +++ src/OFMutableDictionary_hashtable.m @@ -58,12 +58,12 @@ return; if (newSize == 0) @throw [OFOutOfRangeException exceptionWithClass: isa]; - newData = [self allocMemoryWithItemSize: sizeof(*newData) - count: newSize]; + newData = [self allocMemoryWithSize: sizeof(*newData) + count: newSize]; for (i = 0; i < newSize; i++) newData[i] = NULL; for (i = 0; i < size; i++) { Index: src/OFMutableSet.m ================================================================== --- src/OFMutableSet.m +++ src/OFMutableSet.m @@ -157,12 +157,12 @@ { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; size_t count = [self count]; id *cArray; - cArray = [self allocMemoryWithItemSize: sizeof(id) - count: count]; + cArray = [self allocMemoryWithSize: sizeof(id) + count: count]; @try { OFEnumerator *enumerator = [self objectEnumerator]; id object; size_t i = 0; Index: src/OFMutableString_UTF8.m ================================================================== --- src/OFMutableString_UTF8.m +++ src/OFMutableString_UTF8.m @@ -67,12 +67,12 @@ return; } unicodeLen = [self length]; - unicodeString = [self allocMemoryWithItemSize: sizeof(of_unichar_t) - count: unicodeLen]; + unicodeString = [self allocMemoryWithSize: sizeof(of_unichar_t) + count: unicodeLen]; i = j = 0; newCStringLength = 0; while (i < s->cStringLength) { @@ -176,12 +176,12 @@ return; } if (length > oldLength) { s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength - - oldLength + length + 1]; + size: s->cStringLength - oldLength + + length + 1]; memmove(s->cString + index + length, s->cString + index + oldLength, s->cStringLength - index - oldLength); memcpy(s->cString + index, buffer, length); @@ -206,11 +206,11 @@ s->cStringLength += length; s->cString[s->cStringLength] = '\0'; @try { s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } return; @@ -237,11 +237,11 @@ @throw [OFInvalidEncodingException exceptionWithClass: isa]; } s->hashed = NO; s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + + size: s->cStringLength + UTF8StringLength + 1]; memcpy(s->cString + s->cStringLength, UTF8String, UTF8StringLength + 1); s->cStringLength += UTF8StringLength; s->length += length; @@ -265,11 +265,11 @@ @throw [OFInvalidEncodingException exceptionWithClass: isa]; } s->hashed = NO; s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + + size: s->cStringLength + UTF8StringLength + 1]; memcpy(s->cString + s->cStringLength, UTF8String, UTF8StringLength); s->cStringLength += UTF8StringLength; s->length += length; @@ -312,11 +312,11 @@ UTF8StringLength = [string UTF8StringLength]; s->hashed = NO; s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + + size: s->cStringLength + UTF8StringLength + 1]; memcpy(s->cString + s->cStringLength, [string UTF8String], UTF8StringLength); s->cStringLength += UTF8StringLength; @@ -451,11 +451,11 @@ s->cStringLength); newCStringLength = s->cStringLength + [string UTF8StringLength]; s->hashed = NO; s->cString = [self resizeMemory: s->cString - toSize: newCStringLength + 1]; + size: newCStringLength + 1]; memmove(s->cString + index + [string UTF8StringLength], s->cString + index, s->cStringLength - index); memcpy(s->cString + index, [string UTF8String], [string UTF8StringLength]); @@ -494,11 +494,11 @@ s->cStringLength -= end - start; s->cString[s->cStringLength] = 0; @try { s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } @@ -523,11 +523,11 @@ newCStringLength = s->cStringLength - (end - start) + [replacement UTF8StringLength]; s->hashed = NO; s->cString = [self resizeMemory: s->cString - toSize: newCStringLength + 1]; + size: newCStringLength + 1]; memmove(s->cString + start + [replacement UTF8StringLength], s->cString + end, s->cStringLength - end); memcpy(s->cString + start, [replacement UTF8String], [replacement UTF8StringLength]); @@ -570,11 +570,11 @@ continue; @try { newCString = [self resizeMemory: newCString - toSize: newCStringLength + i - last + + size: newCStringLength + i - last + replacementLength + 1]; } @catch (id e) { [self freeMemory: newCString]; @throw e; } @@ -589,14 +589,13 @@ i += searchLength - 1; last = i + 1; } @try { - newCString = [self - resizeMemory: newCString - toSize: newCStringLength + - s->cStringLength - last + 1]; + newCString = [self resizeMemory: newCString + size: newCStringLength + + s->cStringLength - last + 1]; } @catch (id e) { [self freeMemory: newCString]; @throw e; } memcpy(newCString + newCStringLength, s->cString + last, @@ -628,11 +627,11 @@ memmove(s->cString, s->cString + i, s->cStringLength); s->cString[s->cStringLength] = '\0'; @try { s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } @@ -656,11 +655,11 @@ s->cStringLength -= d; s->length -= d; @try { s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } @@ -696,11 +695,11 @@ memmove(s->cString, s->cString + i, s->cStringLength); s->cString[s->cStringLength] = '\0'; @try { s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -499,16 +499,16 @@ * \brief Allocates memory for the specified number of items and stores it in * the object's memory pool. * * It will be free'd automatically when the object is deallocated. * - * \param itemSize The size of each item to allocate + * \param size The size of each item to allocate * \param count The number of items to allocate * \return A pointer to the allocated memory */ -- (void*)allocMemoryWithItemSize: (size_t)itemSize - count: (size_t)count; +- (void*)allocMemoryWithSize: (size_t)size + count: (size_t)count; /** * \brief Resizes memory in the object's memory pool to the specified size. * * If the pointer is NULL, this is equivalent to allocating memory. @@ -517,26 +517,26 @@ * \param pointer A pointer to the already allocated memory * \param size The new size for the memory chunk * \return A pointer to the resized memory chunk */ - (void*)resizeMemory: (void*)pointer - toSize: (size_t)size; + size: (size_t)size; /** * \brief Resizes memory in the object's memory pool to the specific number of * items of the specified size. * * If the pointer is NULL, this is equivalent to allocating memory. * If the size or number of items is 0, this is equivalent to freeing memory. * * \param pointer A pointer to the already allocated memory - * \param itemSize The size of each item to resize to + * \param size The size of each item to resize to * \param count The number of items to resize to * \return A pointer to the resized memory chunk */ - (void*)resizeMemory: (void*)pointer - itemSize: (size_t)itemSize + size: (size_t)size count: (size_t)count; /** * \brief Frees allocated memory and removes it from the object's memory pool. * Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -801,24 +801,24 @@ PRE_IVAR->lastMem = preMem; return (char*)pointer + PRE_MEM_ALIGN; } -- (void*)allocMemoryWithItemSize: (size_t)itemSize - count: (size_t)count +- (void*)allocMemoryWithSize: (size_t)size + count: (size_t)count { - if (itemSize == 0 || count == 0) + if (size == 0 || count == 0) return NULL; - if (count > SIZE_MAX / itemSize) + if (count > SIZE_MAX / size) @throw [OFOutOfRangeException exceptionWithClass: isa]; - return [self allocMemoryWithSize: itemSize * count]; + return [self allocMemoryWithSize: size * count]; } - (void*)resizeMemory: (void*)pointer - toSize: (size_t)size + size: (size_t)size { void *new; struct pre_mem *preMem; if (pointer == NULL) @@ -853,27 +853,27 @@ return (char*)new + PRE_MEM_ALIGN; } - (void*)resizeMemory: (void*)pointer - itemSize: (size_t)itemSize + size: (size_t)size count: (size_t)count { if (pointer == NULL) - return [self allocMemoryWithItemSize: itemSize - count: count]; + return [self allocMemoryWithSize: size + count: count]; - if (itemSize == 0 || count == 0) { + if (size == 0 || count == 0) { [self freeMemory: pointer]; return NULL; } - if (count > SIZE_MAX / itemSize) + if (count > SIZE_MAX / size) @throw [OFOutOfRangeException exceptionWithClass: isa]; return [self resizeMemory: pointer - toSize: itemSize * count]; + size: size * count]; } - (void)freeMemory: (void*)pointer { if (pointer == NULL) @@ -1030,26 +1030,26 @@ { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } -+ (void*)allocMemoryWithItemSize: (size_t)itemSize - count: (size_t)count ++ (void*)allocMemoryWithSize: (size_t)size + count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } + (void*)resizeMemory: (void*)pointer - toSize: (size_t)size + size: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } + (void*)resizeMemory: (void*)pointer - itemSize: (size_t)itemSize + size: (size_t)size count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -89,12 +89,12 @@ case 0:; OFString **objects = [arguments objects]; size_t i, count = [arguments count]; char **argv; - argv = [self allocMemoryWithItemSize: sizeof(char*) - count: count + 2]; + argv = [self allocMemoryWithSize: sizeof(char*) + count: count + 2]; argv[0] = (char*)[programName cStringWithEncoding: OF_STRING_ENCODING_NATIVE]; for (i = 0; i < count; i++) Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -444,12 +444,12 @@ { OFDataArray *dataArray; char *tmp; dataArray = [OFDataArray dataArrayWithItemSize: itemSize]; - tmp = [self allocMemoryWithItemSize: itemSize - count: nItems]; + tmp = [self allocMemoryWithSize: itemSize + count: nItems]; @try { [self readIntoBuffer: tmp exactLength: nItems * itemSize]; @@ -607,11 +607,11 @@ * Append data to cache to prevent loss * of data due to wrong encoding. */ cache = [self resizeMemory: cache - toSize: cacheLength + + size: cacheLength + bufferLength]; if (cache != NULL) memcpy(cache + cacheLength, buffer, bufferLength); @@ -638,15 +638,15 @@ } } /* There was no newline or \0 */ cache = [self resizeMemory: cache - toSize: cacheLength + bufferLength]; + size: cacheLength + bufferLength]; /* * It's possible that cacheLen + len is 0 and thus cache was - * set to NULL by resizeMemory:toSize:. + * set to NULL by resizeMemory:size:. */ if (cache != NULL) memcpy(cache + cacheLength, buffer, bufferLength); cacheLength += bufferLength; @@ -801,15 +801,15 @@ } } /* Neither the delimiter nor \0 was found */ cache = [self resizeMemory: cache - toSize: cacheLength + bufferLength]; + size: cacheLength + bufferLength]; /* * It's possible that cacheLen + len is 0 and thus cache was - * set to NULL by resizeMemory:toSize:. + * set to NULL by resizeMemory:size:. */ if (cache != NULL) memcpy(cache + cacheLength, buffer, bufferLength); @@ -878,11 +878,11 @@ if (!writeBufferEnabled) [self _writeBuffer: buffer length: length]; else { writeBuffer = [self resizeMemory: writeBuffer - toSize: writeBufferLength + length]; + size: writeBufferLength + length]; memcpy(writeBuffer + writeBufferLength, buffer, length); writeBufferLength += length; } } @@ -941,12 +941,12 @@ [self writeBuffer: buffer length: size]; #else uint16_t *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(uint16_t) - count: nInt16s]; + tmp = [self allocMemoryWithSize: sizeof(uint16_t) + count: nInt16s]; @try { size_t i; for (i = 0; i < nInt16s; i++) @@ -971,12 +971,12 @@ [self writeBuffer: buffer length: size]; #else uint32_t *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(uint32_t) - count: nInt32s]; + tmp = [self allocMemoryWithSize: sizeof(uint32_t) + count: nInt32s]; @try { size_t i; for (i = 0; i < nInt32s; i++) @@ -1001,12 +1001,12 @@ [self writeBuffer: buffer length: size]; #else uint64_t *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(uint64_t) - count: nInt64s]; + tmp = [self allocMemoryWithSize: sizeof(uint64_t) + count: nInt64s]; @try { size_t i; for (i = 0; i < nInt64s; i++) @@ -1031,12 +1031,12 @@ [self writeBuffer: buffer length: size]; #else float *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(float) - count: nFloats]; + tmp = [self allocMemoryWithSize: sizeof(float) + count: nFloats]; @try { size_t i; for (i = 0; i < nFloats; i++) @@ -1061,12 +1061,12 @@ [self writeBuffer: buffer length: size]; #else double *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(double) - count: nDoubles]; + tmp = [self allocMemoryWithSize: sizeof(double) + count: nDoubles]; @try { size_t i; for (i = 0; i < nDoubles; i++) @@ -1131,12 +1131,12 @@ [self writeBuffer: buffer length: size]; #else uint16_t *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(uint16_t) - count: nInt16s]; + tmp = [self allocMemoryWithSize: sizeof(uint16_t) + count: nInt16s]; @try { size_t i; for (i = 0; i < nInt16s; i++) @@ -1161,12 +1161,12 @@ [self writeBuffer: buffer length: size]; #else uint32_t *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(uint32_t) - count: nInt32s]; + tmp = [self allocMemoryWithSize: sizeof(uint32_t) + count: nInt32s]; @try { size_t i; for (i = 0; i < nInt32s; i++) @@ -1191,12 +1191,12 @@ [self writeBuffer: buffer length: size]; #else uint64_t *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(uint64_t) - count: nInt64s]; + tmp = [self allocMemoryWithSize: sizeof(uint64_t) + count: nInt64s]; @try { size_t i; for (i = 0; i < nInt64s; i++) @@ -1221,12 +1221,12 @@ [self writeBuffer: buffer length: size]; #else float *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(float) - count: nFloats]; + tmp = [self allocMemoryWithSize: sizeof(float) + count: nFloats]; @try { size_t i; for (i = 0; i < nFloats; i++) @@ -1251,12 +1251,12 @@ [self writeBuffer: buffer length: size]; #else double *tmp; - tmp = [self allocMemoryWithItemSize: sizeof(double) - count: nDoubles]; + tmp = [self allocMemoryWithSize: sizeof(double) + count: nDoubles]; @try { size_t i; for (i = 0; i < nDoubles; i++) Index: src/OFStreamObserver.m ================================================================== --- src/OFStreamObserver.m +++ src/OFStreamObserver.m @@ -137,12 +137,12 @@ @throw [OFInitializationFailedException exceptionWithClass: isa]; #endif maxFD = cancelFD[0]; - FDToStream = [self allocMemoryWithItemSize: sizeof(OFStream*) - count: maxFD + 1]; + FDToStream = [self allocMemoryWithSize: sizeof(OFStream*) + count: maxFD + 1]; FDToStream[cancelFD[0]] = nil; #ifdef OF_THREADS mutex = [[OFMutex alloc] init]; #endif @@ -310,11 +310,11 @@ if ((action & QUEUE_ACTION) == QUEUE_ADD) { if (fd > maxFD) { maxFD = fd; FDToStream = [self resizeMemory: FDToStream - itemSize: sizeof(OFStream*) + size: sizeof(OFStream*) count: maxFD + 1]; } FDToStream[fd] = stream; } Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -997,11 +997,11 @@ UTF8String[j] = '\0'; @try { UTF8String = [object resizeMemory: UTF8String - toSize: UTF8StringLength + 1]; + size: UTF8StringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } return UTF8String; @@ -1521,12 +1521,12 @@ int compare; if ((prefixLength = [prefix length]) > [self length]) return NO; - tmp = [self allocMemoryWithItemSize: sizeof(of_unichar_t) - count: prefixLength]; + tmp = [self allocMemoryWithSize: sizeof(of_unichar_t) + count: prefixLength]; @try { OFAutoreleasePool *pool; [self getCharacters: tmp inRange: of_range(0, prefixLength)]; @@ -1555,12 +1555,12 @@ if ((suffixLength = [suffix length]) > [self length]) return NO; length = [self length]; - tmp = [self allocMemoryWithItemSize: sizeof(of_unichar_t) - count: suffixLength]; + tmp = [self allocMemoryWithSize: sizeof(of_unichar_t) + count: suffixLength]; @try { OFAutoreleasePool *pool; [self getCharacters: tmp inRange: of_range(length - suffixLength, @@ -1957,12 +1957,12 @@ { OFObject *object = [[[OFObject alloc] init] autorelease]; size_t length = [self length]; of_unichar_t *ret; - ret = [object allocMemoryWithItemSize: sizeof(of_unichar_t) - count: length + 1]; + ret = [object allocMemoryWithSize: sizeof(of_unichar_t) + count: length + 1]; [self getCharacters: ret inRange: of_range(0, length)]; ret[length] = 0; return ret; @@ -1976,12 +1976,12 @@ size_t length = [self length]; uint16_t *ret; size_t i, j; /* Allocate memory for the worst case */ - ret = [object allocMemoryWithItemSize: sizeof(uint16_t) - count: length * 2 + 1]; + ret = [object allocMemoryWithSize: sizeof(uint16_t) + count: length * 2 + 1]; j = 0; for (i = 0; i < length; i++) { of_unichar_t c = unicodeString[i]; @@ -2000,11 +2000,11 @@ ret[j] = 0; @try { ret = [object resizeMemory: ret - itemSize: sizeof(uint16_t) + size: sizeof(uint16_t) count: j + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -179,11 +179,11 @@ exceptionWithClass: isa]; s->cStringLength += bytes - 1; s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; memcpy(s->cString + j, buffer, bytes); j += bytes; } @@ -228,11 +228,11 @@ @throw [OFInvalidEncodingException exceptionWithClass: isa]; s->cStringLength += characterBytes - 1; s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; memcpy(s->cString + j, buffer, characterBytes); j += characterBytes; } @@ -340,11 +340,11 @@ s->cString[j] = '\0'; @try { s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } } @catch (id e) { [self release]; @@ -448,11 +448,11 @@ s->cString[j] = '\0'; @try { s->cString = [self resizeMemory: s->cString - toSize: s->cStringLength + 1]; + size: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only tried to make it smaller */ } } @catch (id e) { [self release]; @@ -1092,12 +1092,12 @@ { OFObject *object = [[[OFObject alloc] init] autorelease]; of_unichar_t *ret; size_t i, j; - ret = [object allocMemoryWithItemSize: sizeof(of_unichar_t) - count: s->length + 1]; + ret = [object allocMemoryWithSize: sizeof(of_unichar_t) + count: s->length + 1]; i = 0; j = 0; while (i < s->cStringLength) { Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -513,11 +513,11 @@ if (prefix != nil && ![ns isEqual: defaultNS]) { length += [prefix UTF8StringLength] + 1; @try { cString = [self resizeMemory: cString - toSize: length]; + size: length]; } @catch (id e) { [self freeMemory: cString]; @throw e; } @@ -534,11 +534,11 @@ if (prefix == nil && ((ns != nil && ![ns isEqual: defaultNS]) || (ns == nil && defaultNS != nil))) { length += [ns UTF8StringLength] + 9; @try { cString = [self resizeMemory: cString - toSize: length]; + size: length]; } @catch (id e) { [self freeMemory: cString]; @throw e; } @@ -573,11 +573,11 @@ [attributePrefix UTF8StringLength] + 1 : 0) + [tmp UTF8StringLength] + 4; @try { cString = [self resizeMemory: cString - toSize: length]; + size: length]; } @catch (id e) { [self freeMemory: cString]; @throw e; } @@ -649,11 +649,11 @@ length += [tmp count] + [name UTF8StringLength] + 2 + (indent ? level * indentation : 0); @try { cString = [self resizeMemory: cString - toSize: length]; + size: length]; } @catch (id e) { [self freeMemory: cString]; @throw e; } @@ -671,11 +671,11 @@ cString[i++] = '/'; if (prefix != nil) { length += [prefix UTF8StringLength] + 1; @try { cString = [self resizeMemory: cString - toSize: length]; + size: length]; } @catch (id e) { [self freeMemory: cString]; @throw e; } Index: tests/OFObjectTests.m ================================================================== --- tests/OFObjectTests.m +++ tests/OFObjectTests.m @@ -64,22 +64,22 @@ EXPECT_EXCEPTION(@"Detect out of memory on resize", OFOutOfMemoryException, { p = [obj allocMemoryWithSize: 1]; [obj resizeMemory: p - toSize: SIZE_MAX - 128]; + size: SIZE_MAX - 128]; }) [obj freeMemory: p]; TEST(@"Allocate when trying to resize NULL", (p = [obj resizeMemory: NULL - toSize: 1024]) != NULL) + size: 1024]) != NULL) [obj freeMemory: p]; EXPECT_EXCEPTION(@"Detect resizing of memory not allocated by object", OFMemoryNotPartOfObjectException, [obj resizeMemory: tmp - toSize: 2048]) + size: 2048]) [self freeMemory: tmp]; TEST(@"+[description]", [[OFObject description] isEqual: @"OFObject"] && [[MyObj description] isEqual: @"MyObj"])