Overview
Comment: | OFDataArray: Return void*, but accept const void*. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
4cad2a499bba75c0d77c8a43767248e7 |
User & Date: | js on 2011-02-08 17:22:23 |
Other Links: | manifest | tags |
Context
2011-02-09
| ||
09:19 | Check for NSObject.h instead of Foundation.h. Really speeds things up. check-in: 550c482466 user: js tags: trunk | |
2011-02-08
| ||
17:22 | OFDataArray: Return void*, but accept const void*. check-in: 4cad2a499b user: js tags: trunk | |
12:11 | Use xmlns if there is no prefix for the namespace. check-in: 783ccbbad8 user: js tags: trunk | |
Changes
Modified src/OFDataArray.h from [77e68189e1] to [a50c0cfed5].
︙ | ︙ | |||
123 124 125 126 127 128 129 | - (void*)lastItem; /** * Adds an item to the OFDataArray. * * \param item A pointer to an arbitrary item */ | | | | | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | - (void*)lastItem; /** * Adds an item to the OFDataArray. * * \param item A pointer to an arbitrary item */ - (void)addItem: (const void*)item; /** * Adds an item to the OFDataArray at the specified index. * * \param item A pointer to an arbitrary item * \param index The index where the item should be added */ - (void)addItem: (const void*)item atIndex: (size_t)index; /** * Adds items from a C array to the OFDataArray. * * \param nitems The number of items to add * \param carray A C array containing the items to add */ - (void)addNItems: (size_t)nitems fromCArray: (const void*)carray; /** * Adds items from a C array to the OFDataArray at the specified index. * * \param nitems The number of items to add * \param carray A C array containing the items to add * \param index The index where the items should be added */ - (void)addNItems: (size_t)nitems fromCArray: (const void*)carray atIndex: (size_t)index; /** * Removes the item at the specified index. * * \param index The index of the item to remove */ |
︙ | ︙ |
Modified src/OFDataArray.m from [9cc6f38d56] to [5efff8afd2].
︙ | ︙ | |||
162 163 164 165 166 167 168 | { if (data == NULL || count == 0) return NULL; return data + (count - 1) * itemSize; } | | | | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | { if (data == NULL || count == 0) return NULL; return data + (count - 1) * itemSize; } - (void)addItem: (const void*)item { if (SIZE_MAX - count < 1) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data toNItems: count + 1 withSize: itemSize]; memcpy(data + count * itemSize, item, itemSize); count++; } - (void)addItem: (const void*)item atIndex: (size_t)index { [self addNItems: 1 fromCArray: item atIndex: index]; } - (void)addNItems: (size_t)nitems fromCArray: (const void*)carray { if (nitems > SIZE_MAX - count) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data toNItems: count + nitems withSize: itemSize]; memcpy(data + count * itemSize, carray, nitems * itemSize); count += nitems; } - (void)addNItems: (size_t)nitems fromCArray: (const void*)carray atIndex: (size_t)index { if (nitems > SIZE_MAX - count) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data toNItems: count + nitems |
︙ | ︙ | |||
331 332 333 334 335 336 337 | - (OFString*)stringByBase64Encoding { return of_base64_encode(data, count * itemSize); } @end @implementation OFBigDataArray | | | | | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | - (OFString*)stringByBase64Encoding { return of_base64_encode(data, count * itemSize); } @end @implementation OFBigDataArray - (void)addItem: (const void*)item { size_t nsize, lastpagebyte; if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize) @throw [OFOutOfRangeException newWithClass: isa]; lastpagebyte = of_pagesize - 1; nsize = ((count + 1) * itemSize + lastpagebyte) & ~lastpagebyte; if (size != nsize) data = [self resizeMemory: data toSize: nsize]; memcpy(data + count * itemSize, item, itemSize); count++; size = nsize; } - (void)addNItems: (size_t)nitems fromCArray: (const void*)carray { size_t nsize, lastpagebyte; if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize) @throw [OFOutOfRangeException newWithClass: isa]; lastpagebyte = of_pagesize - 1; nsize = ((count + nitems) * itemSize + lastpagebyte) & ~lastpagebyte; if (size != nsize) data = [self resizeMemory: data toSize: nsize]; memcpy(data + count * itemSize, carray, nitems * itemSize); count += nitems; size = nsize; } - (void)addNItems: (size_t)nitems fromCArray: (const void*)carray atIndex: (size_t)index { size_t nsize, lastpagebyte; if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize) @throw [OFOutOfRangeException newWithClass: isa]; |
︙ | ︙ |