@@ -30,12 +30,11 @@ * for OFDataArrays with item size 1. */ @interface OFDataArray: OFObject { uint8_t *_items; - size_t _count; - size_t _itemSize; + size_t _count, _itemSize, _capacity; } #ifdef OF_HAVE_PROPERTIES @property (readonly) void *items; @property (readonly) size_t count; @@ -56,10 +55,21 @@ * @param itemSize The size of a single element in the OFDataArray * @return A new autoreleased OFDataArray */ + (instancetype)dataArrayWithItemSize: (size_t)itemSize; +/*! + * @brief Creates a new OFDataArray with enough memory to hold the specified + * number of items which all have the same specified size. + * + * @param itemSize The size of a single element in the OFDataArray + * @param capacity The initial capacity for the OFDataArray + * @return A new autoreleased OFDataArray + */ ++ (instancetype)dataArrayWithItemSize: (size_t)itemSize + capacity: (size_t)capacity; + /*! * @brief Creates a new OFDataArary with an item size of 1, containing the data * of the specified file. * * @param path The path of the file @@ -101,10 +111,22 @@ * @param itemSize The size of a single element in the OFDataArray * @return An initialized OFDataArray */ - initWithItemSize: (size_t)itemSize; +/*! + * @brief Initializes an already allocated OFDataArray with enough memory to + * hold the specified number of items which all have the same specified + * size. + * + * @param itemSize The size of a single element in the OFDataArray + * @param capacity The initial capacity for the OFDataArray + * @return An initialized OFDataArray + */ +- initWithItemSize: (size_t)itemSize + capacity: (size_t)capacity; + /*! * @brief Initializes an already allocated OFDataArray with an item size of 1, * containing the data of the specified file. * * @param path The path of the file