Index: src/OFArray_adjacent.m ================================================================== --- src/OFArray_adjacent.m +++ src/OFArray_adjacent.m @@ -109,12 +109,12 @@ @try { for (i = 0; i < count; i++) [objects[i] retain]; - [array addItemsFromCArray: objects - count: count]; + [array addItems: objects + count: count]; } @catch (id e) { for (i = 0; i < count; i++) [objects[i] release]; /* Prevent double-release of objects */ @@ -146,12 +146,12 @@ if (!ok) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; - [array addItemsFromCArray: objects - count: count]; + [array addItems: objects + count: count]; } @catch (id e) { size_t i; for (i = 0; i < count; i++) [objects[i] release]; @@ -207,11 +207,11 @@ return [array count]; } - (id*)objects { - return [array cArray]; + return [array items]; } - (id)objectAtIndex: (size_t)index { return *((id*)[array itemAtIndex: index]); @@ -223,11 +223,11 @@ } - (void)getObjects: (id*)buffer inRange: (of_range_t)range { - id *objects = [array cArray]; + id *objects = [array items]; size_t i, count = [array count]; if (range.length > SIZE_MAX - range.location || range.location + range.length > count) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; @@ -242,11 +242,11 @@ size_t i, count; if (object == nil) return OF_NOT_FOUND; - objects = [array cArray]; + objects = [array items]; count = [array count]; for (i = 0; i < count; i++) if ([objects[i] isEqual: object]) return i; @@ -260,11 +260,11 @@ size_t i, count; if (object == nil) return OF_NOT_FOUND; - objects = [array cArray]; + objects = [array items]; count = [array count]; for (i = 0; i < count; i++) if (objects[i] == object) return i; @@ -280,11 +280,11 @@ @throw [OFOutOfRangeException exceptionWithClass: [self class]]; if ([self isKindOfClass: [OFMutableArray class]]) return [OFArray - arrayWithObjects: (id*)[array cArray] + range.location + arrayWithObjects: (id*)[array items] + range.location count: range.length]; return [OFArray_adjacentSubarray arrayWithArray: self range: range]; } @@ -305,11 +305,11 @@ count = [array count]; if (count != [otherArray count]) return NO; - objects = [array cArray]; + objects = [array items]; otherObjects = [otherArray objects]; for (i = 0; i < count; i++) if (![objects[i] isEqual: otherObjects[i]]) return NO; @@ -317,11 +317,11 @@ return YES; } - (uint32_t)hash { - id *objects = [array cArray]; + id *objects = [array items]; size_t i, count = [array count]; uint32_t hash; OF_HASH_INIT(hash); @@ -334,11 +334,11 @@ } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { - id *objects = [array cArray]; + id *objects = [array items]; size_t i, count = [array count]; BOOL stop = NO; for (i = 0; i < count && !stop; i++) block(objects[i], i, &stop); @@ -345,11 +345,11 @@ } #endif - (void)dealloc { - id *objects = [array cArray]; + id *objects = [array items]; size_t i, count = [array count]; for (i = 0; i < count; i++) [objects[i] release]; Index: src/OFDataArray+Hashing.m ================================================================== --- src/OFDataArray+Hashing.m +++ src/OFDataArray+Hashing.m @@ -32,11 +32,11 @@ OFMD5Hash *hash = [OFMD5Hash hash]; uint8_t *digest; char cString[OF_MD5_DIGEST_SIZE * 2]; size_t i; - [hash updateWithBuffer: data + [hash updateWithBuffer: items length: count * itemSize]; digest = [hash digest]; for (i = 0; i < OF_MD5_DIGEST_SIZE; i++) { uint8_t high, low; @@ -50,11 +50,11 @@ objc_autoreleasePoolPop(pool); return [OFString stringWithCString: cString encoding: OF_STRING_ENCODING_ASCII - length: 32]; + length: OF_MD5_DIGEST_SIZE * 2]; } - (OFString*)SHA1Hash { void *pool = objc_autoreleasePoolPush(); @@ -61,11 +61,11 @@ OFSHA1Hash *hash = [OFSHA1Hash hash]; uint8_t *digest; char cString[OF_SHA1_DIGEST_SIZE * 2]; size_t i; - [hash updateWithBuffer: data + [hash updateWithBuffer: items length: count * itemSize]; digest = [hash digest]; for (i = 0; i < OF_SHA1_DIGEST_SIZE; i++) { uint8_t high, low; @@ -79,8 +79,8 @@ objc_autoreleasePoolPop(pool); return [OFString stringWithCString: cString encoding: OF_STRING_ENCODING_ASCII - length: 40]; + length: OF_SHA1_DIGEST_SIZE * 2]; } @end Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -29,17 +29,17 @@ * For security reasons, serialization and deserialization is only implemented * for OFDataArrays with item size 1. */ @interface OFDataArray: OFObject { - uint8_t *data; + uint8_t *items; size_t count; size_t itemSize; } #ifdef OF_HAVE_PROPERTIES -@property (readonly, getter=cArray) void *data; +@property (readonly) void *items; @property (readonly) size_t count; @property (readonly) size_t itemSize; #endif /*! @@ -151,20 +151,20 @@ * @return The size of each item in the OFDataArray in bytes */ - (size_t)itemSize; /*! - * @brief Returns all elements of the OFDataArray as a C array. + * @brief Returns all items of the OFDataArray as a C array. * * @warning The pointer is only valid until the OFDataArray is changed! * * Modifying the returned array directly is allowed and will change the contents * of the data array. * * @return All elements of the OFDataArray as a C array */ -- (void*)cArray OF_RETURNS_INNER_POINTER; +- (void*)items OF_RETURNS_INNER_POINTER; /*! * @brief Returns a specific item of the OFDataArray. * * @param index The number of the item to return @@ -204,25 +204,25 @@ /*! * @brief Adds items from a C array to the OFDataArray. * * @param count The number of items to add - * @param cArray A C array containing the items to add + * @param items A C array containing the items to add */ -- (void)addItemsFromCArray: (const void*)cArray - count: (size_t)count; +- (void)addItems: (const void*)array + count: (size_t)count; /*! * @brief Adds items from a C array to the OFDataArray at the specified index. * - * @param cArray A C array containing the items to add + * @param items A C array containing the items to add * @param index The index where the items should be added * @param count The number of items to add */ -- (void)insertItemsFromCArray: (const void*)cArray - atIndex: (size_t)index - count: (size_t)count; +- (void)insertItems: (const void*)items + atIndex: (size_t)index + count: (size_t)count; /*! * @brief Removes the item at the specified index. * * @param index The index of the item to remove Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -118,12 +118,12 @@ while (![file isAtEndOfStream]) { size_t length; length = [file readIntoBuffer: buffer length: of_pagesize]; - [self addItemsFromCArray: buffer - count: length]; + [self addItems: buffer + count: length]; } [self freeMemory: buffer]; } @finally { [file release]; @@ -185,11 +185,11 @@ @throw [OFInvalidFormatException exceptionWithClass: [self class]]; count >>= 1; cString = [string UTF8String]; - data = [self allocMemoryWithSize: count]; + items = [self allocMemoryWithSize: count]; for (i = 0; i < count; i++) { uint8_t c1 = cString[2 * i]; uint8_t c2 = cString[2 * i + 1]; uint8_t byte; @@ -212,11 +212,11 @@ byte |= c2 - 'A' + 10; else @throw [OFInvalidFormatException exceptionWithClass: [self class]]; - data[i] = byte; + items[i] = byte; } } @catch (id e) { [self release]; @throw e; } @@ -288,91 +288,91 @@ - (size_t)itemSize { return itemSize; } -- (void*)cArray +- (void*)items { - return data; + return items; } - (void*)itemAtIndex: (size_t)index { if (index >= count) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; - return data + index * itemSize; + return items + index * itemSize; } - (void*)firstItem { - if (data == NULL || count == 0) + if (items == NULL || count == 0) return NULL; - return data; + return items; } - (void*)lastItem { - if (data == NULL || count == 0) + if (items == NULL || count == 0) return NULL; - return data + (count - 1) * itemSize; + return items + (count - 1) * itemSize; } - (void)addItem: (const void*)item { if (SIZE_MAX - count < 1) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; - data = [self resizeMemory: data - size: itemSize - count: count + 1]; + items = [self resizeMemory: items + size: itemSize + count: count + 1]; - memcpy(data + count * itemSize, item, itemSize); + memcpy(items + count * itemSize, item, itemSize); count++; } - (void)insertItem: (const void*)item atIndex: (size_t)index { - [self insertItemsFromCArray: item - atIndex: index - count: 1]; -} - -- (void)addItemsFromCArray: (const void*)cArray - count: (size_t)nItems -{ - if (nItems > SIZE_MAX - count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; - - data = [self resizeMemory: data - size: itemSize - count: count + nItems]; - - memcpy(data + count * itemSize, cArray, nItems * itemSize); - count += nItems; -} - -- (void)insertItemsFromCArray: (const void*)cArray - atIndex: (size_t)index - count: (size_t)nItems -{ - if (nItems > SIZE_MAX - count || index > count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; - - data = [self resizeMemory: data - size: itemSize - count: count + nItems]; - - memmove(data + (index + nItems) * itemSize, data + index * itemSize, - (count - index) * itemSize); - memcpy(data + index * itemSize, cArray, nItems * itemSize); - - count += nItems; + [self insertItems: item + atIndex: index + count: 1]; +} + +- (void)addItems: (const void*)items_ + count: (size_t)count_ +{ + if (count_ > SIZE_MAX - count) + @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + + items = [self resizeMemory: items + size: itemSize + count: count + count_]; + + memcpy(items + count * itemSize, items_, count_ * itemSize); + count += count_; +} + +- (void)insertItems: (const void*)items_ + atIndex: (size_t)index + count: (size_t)count_ +{ + if (count_ > SIZE_MAX - count || index > count) + @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + + items = [self resizeMemory: items + size: itemSize + count: count + count_]; + + memmove(items + (index + count_) * itemSize, items + index * itemSize, + (count - index) * itemSize); + memcpy(items + index * itemSize, items_, count_ * itemSize); + + count += count_; } - (void)removeItemAtIndex: (size_t)index { [self removeItemsInRange: of_range(index, 1)]; @@ -382,19 +382,19 @@ { if (range.length > SIZE_MAX - range.location || range.location + range.length > count) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; - memmove(data + range.location * itemSize, - data + (range.location + range.length) * itemSize, + memmove(items + range.location * itemSize, + items + (range.location + range.length) * itemSize, (count - range.location - range.length) * itemSize); count -= range.length; @try { - data = [self resizeMemory: data - size: itemSize - count: count]; + items = [self resizeMemory: items + size: itemSize + count: count]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ } } @@ -403,32 +403,32 @@ if (count == 0) return; count--; @try { - data = [self resizeMemory: data - size: itemSize - count: count]; + items = [self resizeMemory: items + size: itemSize + count: count]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only made it smaller */ } } - (void)removeAllItems { - [self freeMemory: data]; + [self freeMemory: items]; - data = NULL; + items = NULL; count = 0; } - copy { OFDataArray *copy = [[[self class] alloc] initWithItemSize: itemSize]; - [copy addItemsFromCArray: data - count: count]; + [copy addItems: items + count: count]; return copy; } - (BOOL)isEqual: (id)object @@ -441,11 +441,11 @@ otherDataArray = object; if ([otherDataArray count] != count || [otherDataArray itemSize] != itemSize) return NO; - if (memcmp([otherDataArray cArray], data, count * itemSize)) + if (memcmp([otherDataArray items], items, count * itemSize)) return NO; return YES; } @@ -467,11 +467,11 @@ selector: _cmd]; otherCount = [otherDataArray count]; minimumCount = (count > otherCount ? otherCount : count); - if ((comparison = memcmp(data, [otherDataArray cArray], + if ((comparison = memcmp(items, [otherDataArray items], minimumCount * itemSize)) == 0) { if (count > otherCount) return OF_ORDERED_DESCENDING; if (count < otherCount) return OF_ORDERED_ASCENDING; @@ -490,11 +490,11 @@ size_t i; OF_HASH_INIT(hash); for (i = 0; i < count * itemSize; i++) - OF_HASH_ADD(hash, ((char*)data)[i]); + OF_HASH_ADD(hash, ((uint8_t*)items)[i]); OF_HASH_FINALIZE(hash); return hash; } @@ -509,11 +509,11 @@ if (i > 0) [ret appendString: @" "]; for (j = 0; j < itemSize; j++) - [ret appendFormat: @"%02x", data[i * itemSize + j]]; + [ret appendFormat: @"%02x", items[i * itemSize + j]]; } [ret appendString: @">"]; [ret makeImmutable]; @@ -525,28 +525,28 @@ OFMutableString *ret = [OFMutableString string]; size_t i, j; for (i = 0; i < count; i++) for (j = 0; j < itemSize; j++) - [ret appendFormat: @"%02x", data[i * itemSize + j]]; + [ret appendFormat: @"%02x", items[i * itemSize + j]]; [ret makeImmutable]; return ret; } - (OFString*)stringByBase64Encoding { - return of_base64_encode(data, count * itemSize); + return of_base64_encode(items, count * itemSize); } - (void)writeToFile: (OFString*)path { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"wb"]; @try { - [file writeBuffer: data + [file writeBuffer: items length: count * itemSize]; } @finally { [file release]; } } @@ -563,11 +563,11 @@ pool = objc_autoreleasePoolPush(); element = [OFXMLElement elementWithName: [self className] namespace: OF_SERIALIZATION_NS - stringValue: of_base64_encode(data, count * itemSize)]; + stringValue: of_base64_encode(items, count * itemSize)]; [element retain]; objc_autoreleasePoolPop(pool); @@ -585,62 +585,62 @@ lastPageByte = of_pagesize - 1; newSize = ((count + 1) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) - data = [self resizeMemory: data - size: newSize]; + items = [self resizeMemory: items + size: newSize]; - memcpy(data + count * itemSize, item, itemSize); + memcpy(items + count * itemSize, item, itemSize); count++; size = newSize; } -- (void)addItemsFromCArray: (const void*)cArray - count: (size_t)nItems +- (void)addItems: (const void*)items_ + count: (size_t)count_ { size_t newSize, lastPageByte; - if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize) + if (count_ > SIZE_MAX - count || count + count_ > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; lastPageByte = of_pagesize - 1; - newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte; + newSize = ((count + count_) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) - data = [self resizeMemory: data - size: newSize]; + items = [self resizeMemory: items + size: newSize]; - memcpy(data + count * itemSize, cArray, nItems * itemSize); + memcpy(items + count * itemSize, items_, count_ * itemSize); - count += nItems; + count += count_; size = newSize; } -- (void)insertItemsFromCArray: (const void*)cArray - atIndex: (size_t)index - count: (size_t)nItems +- (void)insertItems: (const void*)items_ + atIndex: (size_t)index + count: (size_t)count_ { size_t newSize, lastPageByte; - if (nItems > SIZE_MAX - count || index > count || - count + nItems > SIZE_MAX / itemSize) + if (count_ > SIZE_MAX - count || index > count || + count + count_ > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; lastPageByte = of_pagesize - 1; - newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte; + newSize = ((count + count_) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) - data = [self resizeMemory: data - size: newSize]; + items = [self resizeMemory: items + size: newSize]; - memmove(data + (index + nItems) * itemSize, data + index * itemSize, + memmove(items + (index + count_) * itemSize, items + index * itemSize, (count - index) * itemSize); - memcpy(data + index * itemSize, cArray, nItems * itemSize); + memcpy(items + index * itemSize, items_, count_ * itemSize); - count += nItems; + count += count_; size = newSize; } - (void)removeItemsInRange: (of_range_t)range { @@ -648,21 +648,21 @@ if (range.length > SIZE_MAX - range.location || range.location + range.length > count) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; - memmove(data + range.location * itemSize, - data + (range.location + range.length) * itemSize, + memmove(items + range.location * itemSize, + items + (range.location + range.length) * itemSize, (count - range.location - range.length) * itemSize); count -= range.length; lastPageByte = of_pagesize - 1; newSize = (count * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) - data = [self resizeMemory: data - size: newSize]; + items = [self resizeMemory: items + size: newSize]; size = newSize; } - (void)removeLastItem { @@ -675,12 +675,12 @@ lastPageByte = of_pagesize - 1; newSize = (count * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) { @try { - data = [self resizeMemory: data - size: newSize]; + items = [self resizeMemory: items + size: newSize]; } @catch (OFOutOfMemoryException *e) { /* We don't care, as we only made it smaller */ } size = newSize; @@ -687,12 +687,12 @@ } } - (void)removeAllItems { - [self freeMemory: data]; + [self freeMemory: items]; - data = NULL; + items = NULL; count = 0; size = 0; } @end Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -217,11 +217,11 @@ /* Work around a bug in lighttpd, see above */ [sock flushWriteBuffer]; [sock setWriteBufferEnabled: NO]; if (requestType == OF_HTTP_REQUEST_TYPE_POST) - [sock writeBuffer: [POSTData cArray] + [sock writeBuffer: [POSTData items] length: [POSTData count] * [POSTData itemSize]]; @try { line = [sock readLine]; } @catch (OFInvalidEncodingException *e) { @@ -405,12 +405,12 @@ objc_autoreleasePoolPop(pool2); pool2 = objc_autoreleasePoolPush(); bytesReceived += length; - [data addItemsFromCArray: buffer - count: length]; + [data addItems: buffer + count: length]; toRead -= length; } @try { @@ -443,12 +443,12 @@ request: request]; objc_autoreleasePoolPop(pool2); bytesReceived += length; - [data addItemsFromCArray: buffer - count: length]; + [data addItems: buffer + count: length]; if (contentLengthHeader != nil && bytesReceived >= contentLength) break; } Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -398,12 +398,12 @@ exception: (OFException*)exception { if ([sock_ isAtEndOfStream] || exception != nil) return NO; - [POSTData addItemsFromCArray: buffer - count: length]; + [POSTData addItems: buffer + count: length]; if ([POSTData count] >= contentLength) { @try { [self sendReply]; } @catch (OFWriteFailedException *e) { @@ -499,11 +499,11 @@ [sock writeFormat: @"%@: %@\r\n", key, value]; [sock writeString: @"\r\n"]; if (requestType != OF_HTTP_REQUEST_TYPE_HEAD) - [sock writeBuffer: [replyData cArray] + [sock writeBuffer: [replyData items] length: [replyData count] * [replyData itemSize]]; } @end @implementation OFHTTPServer Index: src/OFMD5Hash.h ================================================================== --- src/OFMD5Hash.h +++ src/OFMD5Hash.h @@ -14,11 +14,11 @@ * file. */ #import "OFHash.h" -#define OF_MD5_DIGEST_SIZE 16 +#define OF_MD5_DIGEST_SIZE 16 /*! * @brief A class which provides functions to create an MD5 hash. */ @interface OFMD5Hash: OFHash Index: src/OFMutableArray_adjacent.m ================================================================== --- src/OFMutableArray_adjacent.m +++ src/OFMutableArray_adjacent.m @@ -63,13 +63,13 @@ atIndex: (size_t)index { id *objects = [array_ objects]; size_t i, count = [array_ count]; - [array insertItemsFromCArray: objects - atIndex: index - count: count]; + [array insertItems: objects + atIndex: index + count: count]; for (i = 0; i < count; i++) [objects[i] retain]; mutations++; @@ -83,11 +83,11 @@ if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; - objects = [array cArray]; + objects = [array items]; count = [array count]; for (i = 0; i < count; i++) { if ([objects[i] isEqual: oldObject]) { [newObject retain]; @@ -107,11 +107,11 @@ if (object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; - objects = [array cArray]; + objects = [array items]; if (index >= [array count]) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; oldObject = objects[index]; @@ -127,11 +127,11 @@ if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; - objects = [array cArray]; + objects = [array items]; count = [array count]; for (i = 0; i < count; i++) { if (objects[i] == oldObject) { [newObject retain]; @@ -150,11 +150,11 @@ if (object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; - objects = [array cArray]; + objects = [array items]; count = [array count]; for (i = 0; i < count; i++) { if ([objects[i] isEqual: object]) { object = objects[i]; @@ -176,11 +176,11 @@ if (object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; - objects = [array cArray]; + objects = [array items]; count = [array count]; for (i = 0; i < count; i++) { if (objects[i] == object) { [array removeItemAtIndex: i]; @@ -202,11 +202,11 @@ mutations++; } - (void)removeAllObjects { - id *objects = [array cArray]; + id *objects = [array items]; size_t i, count = [array count]; for (i = 0; i < count; i++) [objects[i] release]; @@ -213,11 +213,11 @@ [array removeAllItems]; } - (void)removeObjectsInRange: (of_range_t)range { - id *objects = [array cArray], *copy; + id *objects = [array items], *copy; size_t i, count = [array count]; if (range.length > SIZE_MAX - range.location || range.length > count - range.location) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; @@ -253,11 +253,11 @@ } - (void)exchangeObjectAtIndex: (size_t)index1 withObjectAtIndex: (size_t)index2 { - id *objects = [array cArray]; + id *objects = [array items]; size_t count = [array count]; id tmp; if (index1 >= count || index2 >= count) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; @@ -267,11 +267,11 @@ objects[index2] = tmp; } - (void)reverse { - id *objects = [array cArray]; + id *objects = [array items]; size_t i, j, count = [array count]; if (count == 0 || count == 1) return; @@ -308,11 +308,11 @@ } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { - id *objects = [array cArray]; + id *objects = [array items]; size_t i, count = [array count]; BOOL stop = NO; unsigned long mutations_ = mutations; for (i = 0; i < count && !stop; i++) { @@ -325,11 +325,11 @@ } } - (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block { - id *objects = [array cArray]; + id *objects = [array items]; size_t i, count = [array count]; BOOL stop = NO; unsigned long mutations_ = mutations; for (i = 0; i < count && !stop; i++) { Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -498,12 +498,12 @@ @try { [self readIntoBuffer: tmp exactLength: count * itemSize]; - [dataArray addItemsFromCArray: tmp - count: count]; + [dataArray addItems: tmp + count: count]; } @finally { [self freeMemory: tmp]; } return dataArray; @@ -521,12 +521,12 @@ while (![self isAtEndOfStream]) { size_t length; length = [self readIntoBuffer: buffer length: of_pagesize]; - [dataArray addItemsFromCArray: buffer - count: length]; + [dataArray addItems: buffer + count: length]; } } @finally { [self freeMemory: buffer]; } @@ -1355,14 +1355,14 @@ - (size_t)writeDataArray: (OFDataArray*)dataArray { size_t length = [dataArray count] * [dataArray itemSize]; - [self writeBuffer: [dataArray cArray] + [self writeBuffer: [dataArray items] length: length]; - return [dataArray count] * [dataArray itemSize]; + return length; } - (size_t)writeString: (OFString*)string { size_t length = [string UTF8StringLength]; Index: src/OFStreamObserver.m ================================================================== --- src/OFStreamObserver.m +++ src/OFStreamObserver.m @@ -291,18 +291,18 @@ - (void)OF_processQueue { [mutex lock]; @try { OFStream **queueObjects = [queue objects]; - int *queueInfoCArray = [queueInfo cArray]; - int *queueFDsCArray = [queueFDs cArray]; + int *queueInfoItems = [queueInfo items]; + int *queueFDsItems = [queueFDs items]; size_t i, count = [queue count]; for (i = 0; i < count; i++) { OFStream *stream = queueObjects[i]; - int action = queueInfoCArray[i]; - int fd = queueFDsCArray[i]; + int action = queueInfoItems[i]; + int fd = queueFDsItems[i]; if ((action & QUEUE_ACTION) == QUEUE_ADD) { if (fd > maxFD) { maxFD = fd; FDToStream = [self Index: src/OFStreamObserver_kqueue.m ================================================================== --- src/OFStreamObserver_kqueue.m +++ src/OFStreamObserver_kqueue.m @@ -122,11 +122,11 @@ return YES; } objc_autoreleasePoolPop(pool); - events = kevent(kernelQueue, [changeList cArray], + events = kevent(kernelQueue, [changeList items], (int)[changeList count], eventList, EVENTLIST_SIZE, (timeout == -1 ? NULL : ×pec)); if (events == -1) { switch (errno) { Index: src/OFStreamObserver_poll.m ================================================================== --- src/OFStreamObserver_poll.m +++ src/OFStreamObserver_poll.m @@ -58,17 +58,17 @@ } - (void)OF_addFileDescriptor: (int)fd withEvents: (short)events { - struct pollfd *FDsCArray = [FDs cArray]; + struct pollfd *FDs_ = [FDs items]; size_t i, count = [FDs count]; BOOL found = NO; for (i = 0; i < count; i++) { - if (FDsCArray[i].fd == fd) { - FDsCArray[i].events |= events; + if (FDs_[i].fd == fd) { + FDs_[i].events |= events; found = YES; break; } } @@ -79,18 +79,18 @@ } - (void)OF_removeFileDescriptor: (int)fd withEvents: (short)events { - struct pollfd *FDsCArray = [FDs cArray]; + struct pollfd *FDs_ = [FDs items]; size_t i, nFDs = [FDs count]; for (i = 0; i < nFDs; i++) { - if (FDsCArray[i].fd == fd) { - FDsCArray[i].events &= ~events; + if (FDs_[i].fd == fd) { + FDs_[i].events &= ~events; - if ((FDsCArray[i].events & ~POLLERR) == 0) + if ((FDs_[i].events & ~POLLERR) == 0) [FDs removeItemAtIndex: i]; break; } } @@ -121,11 +121,11 @@ } - (BOOL)observeWithTimeout: (double)timeout { void *pool = objc_autoreleasePoolPush(); - struct pollfd *FDsCArray; + struct pollfd *FDs_; size_t i, nFDs, realEvents = 0; [self OF_processQueue]; if ([self OF_processCache]) { @@ -133,54 +133,54 @@ return YES; } objc_autoreleasePoolPop(pool); - FDsCArray = [FDs cArray]; + FDs_ = [FDs items]; nFDs = [FDs count]; #ifdef OPEN_MAX if (nFDs > OPEN_MAX) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #endif - if (poll(FDsCArray, (nfds_t)nFDs, + if (poll(FDs_, (nfds_t)nFDs, (int)(timeout != -1 ? timeout * 1000 : -1)) < 1) return NO; for (i = 0; i < nFDs; i++) { pool = objc_autoreleasePoolPush(); - if (FDsCArray[i].revents & POLLIN) { - if (FDsCArray[i].fd == cancelFD[0]) { + if (FDs_[i].revents & POLLIN) { + if (FDs_[i].fd == cancelFD[0]) { char buffer; OF_ENSURE(read(cancelFD[0], &buffer, 1) > 0); - FDsCArray[i].revents = 0; + FDs_[i].revents = 0; objc_autoreleasePoolPop(pool); continue; } realEvents++; [delegate streamIsReadyForReading: - FDToStream[FDsCArray[i].fd]]; + FDToStream[FDs_[i].fd]]; } - if (FDsCArray[i].revents & POLLOUT) { + if (FDs_[i].revents & POLLOUT) { realEvents++; [delegate streamIsReadyForWriting: - FDToStream[FDsCArray[i].fd]]; + FDToStream[FDs_[i].fd]]; } - if (FDsCArray[i].revents & POLLERR) { + if (FDs_[i].revents & POLLERR) { realEvents++; [delegate streamDidReceiveException: - FDToStream[FDsCArray[i].fd]]; + FDToStream[FDs_[i].fd]]; } - FDsCArray[i].revents = 0; + FDs_[i].revents = 0; objc_autoreleasePoolPop(pool); } if (realEvents == 0) Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -781,11 +781,11 @@ } if (encoding == OF_STRING_ENCODING_AUTODETECT) encoding = OF_STRING_ENCODING_UTF_8; - self = [[c alloc] initWithCString: (char*)[[result data] cArray] + self = [[c alloc] initWithCString: (char*)[[result data] items] encoding: encoding length: [[result data] count]]; objc_autoreleasePoolPop(pool); return self; Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -638,12 +638,12 @@ else child = [childrenObjects[j] XMLStringWithIndentation: ind level: level + 1]; - [tmp addItemsFromCArray: [child UTF8String] - count: [child UTF8StringLength]]; + [tmp addItems: [child UTF8String] + count: [child UTF8StringLength]]; } if (indent) [tmp addItem: "\n"]; @@ -657,11 +657,11 @@ @throw e; } cString[i++] = '>'; - memcpy(cString + i, [tmp cArray], [tmp count]); + memcpy(cString + i, [tmp items], [tmp count]); i += [tmp count]; if (indent) { memset(cString + i, ' ', level * indentation); i += level * indentation; Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -45,50 +45,50 @@ static OF_INLINE void cache_append(OFDataArray *cache, const char *string, of_string_encoding_t encoding, size_t length) { if (OF_LIKELY(encoding == OF_STRING_ENCODING_UTF_8)) - [cache addItemsFromCArray: string - count: length]; + [cache addItems: string + count: length]; else { void *pool = objc_autoreleasePoolPush(); OFString *tmp = [OFString stringWithCString: string encoding: encoding length: length]; - [cache addItemsFromCArray: [tmp UTF8String] - count: [tmp UTF8StringLength]]; + [cache addItems: [tmp UTF8String] + count: [tmp UTF8StringLength]]; objc_autoreleasePoolPop(pool); } } static OFString* transform_string(OFDataArray *cache, size_t cut, BOOL unescape, id delegate) { - char *cArray; + char *items; size_t i, length; BOOL hasEntities = NO; OFMutableString *ret; - cArray = [cache cArray]; + items = [cache items]; length = [cache count] - cut; for (i = 0; i < length; i++) { - if (cArray[i] == '\r') { - if (i + 1 < length && cArray[i + 1] == '\n') { + if (items[i] == '\r') { + if (i + 1 < length && items[i + 1] == '\n') { [cache removeItemAtIndex: i]; - cArray = [cache cArray]; + items = [cache items]; i--; length--; } else - cArray[i] = '\n'; - } else if (cArray[i] == '&') + items[i] = '\n'; + } else if (items[i] == '&') hasEntities = YES; } - ret = [OFMutableString stringWithUTF8String: cArray + ret = [OFMutableString stringWithUTF8String: items length: length]; if (unescape && hasEntities) return [ret stringByXMLUnescapingWithDelegate: delegate]; @@ -535,11 +535,11 @@ if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); pool = objc_autoreleasePoolPush(); - cacheCString = [cache cArray]; + cacheCString = [cache items]; cacheLength = [cache count]; cacheString = [OFString stringWithUTF8String: cacheCString length: cacheLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { @@ -618,11 +618,11 @@ if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); pool = objc_autoreleasePoolPush(); - cacheCString = [cache cArray]; + cacheCString = [cache items]; cacheLength = [cache count]; cacheString = [OFString stringWithUTF8String: cacheCString length: cacheLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { @@ -761,11 +761,11 @@ if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); pool = objc_autoreleasePoolPush(); - cacheString = [OFMutableString stringWithUTF8String: [cache cArray] + cacheString = [OFMutableString stringWithUTF8String: [cache items] length: [cache count]]; [cacheString deleteEnclosingWhitespaces]; /* Prevent a useless copy later */ [cacheString makeImmutable]; Index: src/base64.m ================================================================== --- src/base64.m +++ src/base64.m @@ -148,11 +148,11 @@ db[0] = (sb & 0xFF0000) >> 16; db[1] = (sb & 0x00FF00) >> 8; db[2] = sb & 0x0000FF; - [data addItemsFromCArray: db - count: count]; + [data addItems: db + count: count]; } return YES; } Index: tests/OFDataArrayTests.m ================================================================== --- tests/OFDataArrayTests.m +++ tests/OFDataArrayTests.m @@ -59,12 +59,12 @@ other = (class == [OFDataArray class] ? [OFBigDataArray class] : [OFDataArray class]); TEST(@"-[isEqual:]", (array[1] = [other dataArrayWithItemSize: 4096]) && - R([array[1] addItemsFromCArray: [array[0] cArray] - count: [array[0] count]]) && + R([array[1] addItems: [array[0] items] + count: [array[0] count]]) && [array[1] isEqual: array[0]] && R([array[1] removeLastItem]) && ![array[0] isEqual: array[1]]) TEST(@"-[copy]", (array[1] = [[array[0] copy] autorelease]) && [array[0] isEqual: array[1]]) @@ -81,26 +81,26 @@ [array[2] compare: array[3]] == OF_ORDERED_ASCENDING) TEST(@"-[hash]", [array[0] hash] == 0x634A529F) array[0] = [class dataArray]; - [array[0] addItemsFromCArray: "abcdef" - count: 6]; + [array[0] addItems: "abcdef" + count: 6]; TEST(@"-[removeLastItem]", R([array[0] removeLastItem]) && [array[0] count] == 5 && - !memcmp([array[0] cArray], "abcde", 5)) + !memcmp([array[0] items], "abcde", 5)) TEST(@"-[removeItemsInRange:]", R([array[0] removeItemsInRange: of_range(1, 2)]) && - [array[0] count] == 3 && !memcmp([array[0] cArray], "ade", 3)) + [array[0] count] == 3 && !memcmp([array[0] items], "ade", 3)) - TEST(@"-[insertItemsFromCArray:atIndex:count:]", - R([array[0] insertItemsFromCArray: "bc" - atIndex: 1 - count: 2]) && [array[0] count] == 5 && - !memcmp([array[0] cArray], "abcde", 5)) + TEST(@"-[insertItems:atIndex:count:]", + R([array[0] insertItems: "bc" + atIndex: 1 + count: 2]) && [array[0] count] == 5 && + !memcmp([array[0] items], "abcde", 5)) TEST(@"-[MD5Hash]", [[array[0] MD5Hash] isEqual: [@"abcde" MD5Hash]]) TEST(@"-[SHA1Hash]", [[array[0] SHA1Hash] isEqual: [@"abcde" SHA1Hash]]) @@ -107,25 +107,24 @@ TEST(@"-[stringByBase64Encoding]", [[array[0] stringByBase64Encoding] isEqual: @"YWJjZGU="]) TEST(@"+[dataArrayWithBase64EncodedString:]", !memcmp([[class dataArrayWithBase64EncodedString: @"YWJjZGU="] - cArray], "abcde", 5)) + items], "abcde", 5)) TEST(@"Building strings", (array[0] = [class dataArray]) && - R([array[0] addItemsFromCArray: (void*)str - count: 6]) && R([array[0] addItem: ""]) && - !strcmp([array[0] cArray], str)) + R([array[0] addItems: (void*)str + count: 6]) && R([array[0] addItem: ""]) && + !strcmp([array[0] items], str)) EXPECT_EXCEPTION(@"Detect out of range in -[itemAtIndex:]", OFOutOfRangeException, [array[0] itemAtIndex: [array[0] count]]) - EXPECT_EXCEPTION(@"Detect out of range in " - @"-[addItemsFromCArray:count:]", - OFOutOfRangeException, [array[0] addItemsFromCArray: NULL - count: SIZE_MAX]) + EXPECT_EXCEPTION(@"Detect out of range in -[addItems:count:]", + OFOutOfRangeException, [array[0] addItems: NULL + count: SIZE_MAX]) EXPECT_EXCEPTION(@"Detect out of range in -[removeItemsInRange:]", OFOutOfRangeException, [array[0] removeItemsInRange: of_range([array[0] count], 1)]) } Index: tests/OFSerializationTests.m ================================================================== --- tests/OFSerializationTests.m +++ tests/OFSerializationTests.m @@ -65,12 +65,12 @@ [OFCountedSet setWithObjects: @"foo", @"foo", @"bar", nil]]; [d setObject: @"list" forKey: l]; - [da addItemsFromCArray: "0123456789:;