@@ -43,11 +43,11 @@ @throw [OFInvalidArgumentException newWithClass: c selector: _cmd]; } data = NULL; - itemsize = is; + itemSize = is; return self; } - (size_t)count @@ -55,11 +55,11 @@ return count; } - (size_t)itemSize { - return itemsize; + return itemSize; } - (void*)cArray { return data; @@ -68,11 +68,11 @@ - (void*)itemAtIndex: (size_t)index { if (index >= count) @throw [OFOutOfRangeException newWithClass: isa]; - return data + index * itemsize; + return data + index * itemSize; } - (void*)firstItem { if (data == NULL || count == 0) @@ -84,23 +84,23 @@ - (void*)lastItem { if (data == NULL || count == 0) return NULL; - return data + (count - 1) * itemsize; + return data + (count - 1) * itemSize; } - (void)addItem: (void*)item { if (SIZE_MAX - count < 1) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data toNItems: count + 1 - withSize: itemsize]; + withSize: itemSize]; - memcpy(data + count * itemsize, item, itemsize); + memcpy(data + count * itemSize, item, itemSize); count++; } - (void)addItem: (void*)item @@ -117,13 +117,13 @@ if (nitems > SIZE_MAX - count) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data toNItems: count + nitems - withSize: itemsize]; + withSize: itemSize]; - memcpy(data + count * itemsize, carray, nitems * itemsize); + memcpy(data + count * itemSize, carray, nitems * itemSize); count += nitems; } - (void)addNItems: (size_t)nitems fromCArray: (void*)carray @@ -132,15 +132,15 @@ if (nitems > SIZE_MAX - count) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data toNItems: count + nitems - withSize: itemsize]; + withSize: itemSize]; - memmove(data + (index + nitems) * itemsize, data + index * itemsize, - (count - index) * itemsize); - memcpy(data + index * itemsize, carray, nitems * itemsize); + memmove(data + (index + nitems) * itemSize, data + index * itemSize, + (count - index) * itemSize); + memcpy(data + index * itemSize, carray, nitems * itemSize); count += nitems; } - (void)removeItemAtIndex: (size_t)index @@ -157,11 +157,11 @@ count -= nitems; @try { data = [self resizeMemory: data toNItems: count - withSize: itemsize]; + withSize: itemSize]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } } @@ -170,27 +170,27 @@ atIndex: (size_t)index { if (nitems > count) @throw [OFOutOfRangeException newWithClass: isa]; - memmove(data + index * itemsize, data + (index + nitems) * itemsize, - (count - index - nitems) * itemsize); + memmove(data + index * itemSize, data + (index + nitems) * itemSize, + (count - index - nitems) * itemSize); count -= nitems; @try { data = [self resizeMemory: data toNItems: count - withSize: itemsize]; + withSize: itemSize]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } } - copy { - OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemsize]; + OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemSize]; [new addNItems: count fromCArray: data]; return new; } @@ -198,13 +198,13 @@ - (BOOL)isEqual: (OFObject*)obj { if (![obj isKindOfClass: [OFDataArray class]]) return NO; if ([(OFDataArray*)obj count] != count || - [(OFDataArray*)obj itemSize] != itemsize) + [(OFDataArray*)obj itemSize] != itemSize) return NO; - if (memcmp([(OFDataArray*)obj cArray], data, count * itemsize)) + if (memcmp([(OFDataArray*)obj cArray], data, count * itemSize)) return NO; return YES; } @@ -214,18 +214,18 @@ size_t ary_count, min_count; if (![ary isKindOfClass: [OFDataArray class]]) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; - if ([ary itemSize] != itemsize) + if ([ary itemSize] != itemSize) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; ary_count = [ary count]; min_count = (count > ary_count ? ary_count : count); - if ((cmp = memcmp(data, [ary cArray], min_count * itemsize)) == 0) { + if ((cmp = memcmp(data, [ary cArray], min_count * itemSize)) == 0) { if (count > ary_count) return OF_ORDERED_DESCENDING; if (count < ary_count) return OF_ORDERED_ASCENDING; return OF_ORDERED_SAME; @@ -241,11 +241,11 @@ { uint32_t hash; size_t i; OF_HASH_INIT(hash); - for (i = 0; i < count * itemsize; i++) + for (i = 0; i < count * itemSize; i++) OF_HASH_ADD(hash, ((char*)data)[i]); OF_HASH_FINALIZE(hash); return hash; } @@ -254,21 +254,21 @@ @implementation OFBigDataArray - (void)addItem: (void*)item { size_t nsize, lastpagebyte; - if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemsize) + if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize) @throw [OFOutOfRangeException newWithClass: isa]; lastpagebyte = of_pagesize - 1; - nsize = ((count + 1) * itemsize + lastpagebyte) & ~lastpagebyte; + nsize = ((count + 1) * itemSize + lastpagebyte) & ~lastpagebyte; if (size != nsize) data = [self resizeMemory: data toSize: nsize]; - memcpy(data + count * itemsize, item, itemsize); + memcpy(data + count * itemSize, item, itemSize); count++; size = nsize; } @@ -275,21 +275,21 @@ - (void)addNItems: (size_t)nitems fromCArray: (void*)carray { size_t nsize, lastpagebyte; - if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemsize) + if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize) @throw [OFOutOfRangeException newWithClass: isa]; lastpagebyte = of_pagesize - 1; - nsize = ((count + nitems) * itemsize + lastpagebyte) & ~lastpagebyte; + nsize = ((count + nitems) * itemSize + lastpagebyte) & ~lastpagebyte; if (size != nsize) data = [self resizeMemory: data toSize: nsize]; - memcpy(data + count * itemsize, carray, nitems * itemsize); + memcpy(data + count * itemSize, carray, nitems * itemSize); count += nitems; size = nsize; } @@ -297,24 +297,24 @@ fromCArray: (void*)carray atIndex: (size_t)index { size_t nsize, lastpagebyte; - if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemsize) + if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize) @throw [OFOutOfRangeException newWithClass: isa]; lastpagebyte = of_pagesize - 1; - nsize = ((count + nitems) * itemsize + lastpagebyte) & ~lastpagebyte; + nsize = ((count + nitems) * itemSize + lastpagebyte) & ~lastpagebyte; if (size != nsize) data = [self resizeMemory: data toNItems: nsize - withSize: itemsize]; + withSize: itemSize]; - memmove(data + (index + nitems) * itemsize, data + index * itemsize, - (count - index) * itemsize); - memcpy(data + index * itemsize, carray, nitems * itemsize); + memmove(data + (index + nitems) * itemSize, data + index * itemSize, + (count - index) * itemSize); + memcpy(data + index * itemSize, carray, nitems * itemSize); count += nitems; size = nsize; } @@ -325,11 +325,11 @@ if (nitems > count) @throw [OFOutOfRangeException newWithClass: isa]; count -= nitems; lastpagebyte = of_pagesize - 1; - nsize = (count * itemsize + lastpagebyte) & ~lastpagebyte; + nsize = (count * itemSize + lastpagebyte) & ~lastpagebyte; if (size != nsize) data = [self resizeMemory: data toSize: nsize]; size = nsize; @@ -341,28 +341,28 @@ size_t nsize, lastpagebyte; if (nitems > count) @throw [OFOutOfRangeException newWithClass: isa]; - memmove(data + index * itemsize, data + (index + nitems) * itemsize, - (count - index - nitems) * itemsize); + memmove(data + index * itemSize, data + (index + nitems) * itemSize, + (count - index - nitems) * itemSize); count -= nitems; lastpagebyte = of_pagesize - 1; - nsize = (count * itemsize + lastpagebyte) & ~lastpagebyte; + nsize = (count * itemSize + lastpagebyte) & ~lastpagebyte; if (size != nsize) data = [self resizeMemory: data toSize: nsize]; size = nsize; } - copy { - OFDataArray *new = [[OFBigDataArray alloc] initWithItemSize: itemsize]; + OFDataArray *new = [[OFBigDataArray alloc] initWithItemSize: itemSize]; [new addNItems: count fromCArray: data]; return new; } @end