@@ -337,61 +337,10 @@ return [[[self alloc] initWithCount: count itemSize: itemSize allowsSwappableMemory: allowsSwappableMemory] autorelease]; } - -+ (instancetype)dataWithItems: (const void *)items - count: (size_t)count -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)dataWithItems: (const void *)items - count: (size_t)count - itemSize: (size_t)itemSize -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)dataWithItemsNoCopy: (void *)items - count: (size_t)count - freeWhenDone: (bool)freeWhenDone -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)dataWithItemsNoCopy: (void *)items - count: (size_t)count - itemSize: (size_t)itemSize - freeWhenDone: (bool)freeWhenDone -{ - OF_UNRECOGNIZED_SELECTOR -} - -#ifdef OF_HAVE_FILES -+ (instancetype)dataWithContentsOfFile: (OFString *)path -{ - OF_UNRECOGNIZED_SELECTOR -} -#endif - -+ (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)dataWithStringRepresentation: (OFString *)string -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)dataWithBase64EncodedString: (OFString *)string -{ - OF_UNRECOGNIZED_SELECTOR -} - - (instancetype)initWithCount: (size_t)count allowsSwappableMemory: (bool)allowsSwappableMemory { return [self initWithCount: count @@ -463,33 +412,16 @@ } return self; } -- (instancetype)initWithItems: (const void *)items count: (size_t)count +- (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithItems: (const void *)items - count: (size_t)count - itemSize: (size_t)itemSize -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithItemsNoCopy: (void *)items - count: (size_t)count - freeWhenDone: (bool)freeWhenDone -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithItemsNoCopy: (void *)items - count: (size_t)count - itemSize: (size_t)itemSize - freeWhenDone: (bool)freeWhenDone +- (instancetype)initWithItemSize: (size_t)itemSize { OF_INVALID_INIT_METHOD } #ifdef OF_HAVE_FILES @@ -533,12 +465,30 @@ removePageIfEmpty(_page); } } #endif + if (_freeWhenDone) + OFFreeMemory(_items); + [super dealloc]; } + +- (size_t)count +{ + return _count; +} + +- (size_t)itemSize +{ + return _itemSize; +} + +- (const void *)items +{ + return _items; +} - (void *)mutableItems { return _items; } @@ -581,27 +531,29 @@ } - (bool)isEqual: (id)object { OFData *otherData; + const unsigned char *otherDataItems; unsigned char diff; if (object == self) return true; if (![object isKindOfClass: [OFData class]]) return false; otherData = object; + otherDataItems = otherData.items; - if (otherData->_count != _count || otherData->_itemSize != _itemSize) + if (otherData.count != _count || otherData.itemSize != _itemSize) return false; diff = 0; for (size_t i = 0; i < _count * _itemSize; i++) - diff |= otherData->_items[i] ^ _items[i]; + diff |= otherDataItems[i] ^ _items[i]; return (diff == 0); } - (OFString *)description