Comment: | Rework OFDataArray API.
Also adds more checks. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d5ddb2cb48c73cddb352cdcdaf279a38 |
User & Date: | js on 2012-06-06 13:09:08 |
Other Links: | manifest | tags |
2012-06-06
| ||
13:14 | Remove -[OFMutableArray removeNObjects:]. check-in: 6f0ef1c5e1 user: js tags: trunk | |
13:09 | Rework OFDataArray API. check-in: d5ddb2cb48 user: js tags: trunk | |
12:23 | Add a missing check in OFDataArray. check-in: e68229ff3b user: js tags: trunk | |
Modified src/OFArray_adjacent.m from [c8a1da4bf7] to [7c4a615aae].
︙ | |||
100 101 102 103 104 105 106 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | - - + + | @throw e; } @try { for (i = 0; i < count; i++) [objects[i] retain]; |
︙ | |||
128 129 130 131 132 133 134 | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | - - + + | @try { size_t i; for (i = 0; i < count; i++) [objects[i] retain]; |
︙ |
Modified src/OFDataArray.h from [f2dc48f29f] to [4922f55b79].
︙ | |||
184 185 186 187 188 189 190 | 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 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | - - + + - + - - + + - + - - - + + + - - - - - - - - + - - + - | /** * \brief 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 */ |
︙ |
Modified src/OFDataArray.m from [d431a67a01] to [490fab954b].
︙ | |||
109 110 111 112 113 114 115 | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | - - + + | char *buffer = [self allocMemoryWithSize: of_pagesize]; while (![file isAtEndOfStream]) { size_t length; length = [file readNBytes: of_pagesize intoBuffer: buffer]; |
︙ | |||
261 262 263 264 265 266 267 | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | - - + + - - - + + + - - + + - - - + + + - + - - + - + - + - - - - - - - - - - + - - - - - - + - - - + | ofSize: itemSize]; memcpy(data + count * itemSize, item, itemSize); count++; } |
︙ | |||
369 370 371 372 373 374 375 | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | - - + + | count = 0; } - copy { OFDataArray *copy = [[isa alloc] initWithItemSize: itemSize]; |
︙ | |||
501 502 503 504 505 506 507 | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | - - + + - - - + + + - + + - + - + - - - - + - - - - - - + - - - - - + - - - - - - + | memcpy(data + count * itemSize, item, itemSize); count++; size = newSize; } |
︙ |
Modified src/OFHTTPRequest.m from [4b826a148e] to [456aec5d03].
︙ | |||
427 428 429 430 431 432 433 | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | - - + + | [delegate request: self didReceiveData: buffer withLength: length]; [pool2 releaseObjects]; bytesReceived += length; |
︙ | |||
457 458 459 460 461 462 463 | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | - - + + | intoBuffer: buffer]) > 0) { [delegate request: self didReceiveData: buffer withLength: length]; [pool2 releaseObjects]; bytesReceived += length; |
︙ |
Modified src/OFMutableArray.h from [1edd47fa69] to [7d1dea4d27].
︙ | |||
22 23 24 25 26 27 28 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | - + - + | /** * \brief An abstract class for storing, adding and removing objects in anr * array. */ @interface OFMutableArray: OFArray /** |
︙ |
Modified src/OFMutableArray.m from [e6d36fbf2d] to [9461a9b182].
︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | + + | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <string.h> #include <assert.h> #import "OFMutableArray.h" #import "OFMutableArray_adjacent.h" #import "OFAutoreleasePool.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" |
︙ |
Modified src/OFMutableArray_adjacent.m from [725da742e3] to [168c402c93].
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | + + - - + + | #import "OFArray_adjacent.h" #import "OFDataArray.h" #import "OFAutoreleasePool.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #import "macros.h" @implementation OFMutableArray_adjacent + (void)initialize { if (self == [OFMutableArray_adjacent class]) [self inheritMethodsFromClass: [OFArray_adjacent class]]; } - (void)addObject: (id)object { [array addItem: &object]; [object retain]; mutations++; } - (void)insertObject: (id)object atIndex: (size_t)index { |
︙ | |||
154 155 156 157 158 159 160 | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | - + + | @throw [OFOutOfRangeException exceptionWithClass: isa]; copy = [self allocMemoryForNItems: nObjects ofSize: sizeof(id)]; memcpy(copy, objects + (count - nObjects), nObjects * sizeof(id)); @try { |
︙ | |||
188 189 190 191 192 193 194 | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | - + - | @throw [OFOutOfRangeException exceptionWithClass: isa]; copy = [self allocMemoryForNItems: range.length ofSize: sizeof(id)]; memcpy(copy, objects + range.start, range.length * sizeof(id)); @try { |
︙ |
Modified src/OFStream.m from [79c2ad057e] to [4d96b81ee9].
︙ | |||
438 439 440 441 442 443 444 | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | - + - + - - + + - + - - + + | return [self readDataArrayWithItemSize: 1 andNItems: nItems]; } - (OFDataArray*)readDataArrayWithItemSize: (size_t)itemSize andNItems: (size_t)nItems { |
︙ |
Modified src/OFStreamObserver.m from [89d321be6d] to [9591f1939e].
︙ | |||
350 351 352 353 354 355 356 | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | - - - + + + | break; default: assert(0); } } |
︙ |
Modified src/OFStreamObserver_kqueue.m from [688eaf3047] to [c2387049cc].
︙ | |||
123 124 125 126 127 128 129 | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | - + | [pool release]; @throw [OFOutOfMemoryException exceptionWithClass: isa]; default: assert(0); } } |
︙ |
Modified src/OFXMLElement.m from [05fab1ecc3] to [23e15b2038].
︙ | |||
636 637 638 639 640 641 642 | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | - - + + | indentation: ind level: level + 1]; else child = [childrenObjects[j] XMLStringWithIndentation: ind level: level + 1]; |
︙ |
Modified src/OFXMLParser.m from [8f2d46a92b] to [2619682154].
︙ | |||
41 42 43 44 45 46 47 | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | - - + + - - + + | static state_function lookupTable[OF_XMLPARSER_NUM_STATES]; 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)) |
︙ |
Modified src/base64.m from [467c9771cc] to [b831cbbe10].
︙ | |||
146 147 148 149 150 151 152 | 146 147 148 149 150 151 152 153 154 155 156 157 158 | - - + + | sb |= tmp; db[0] = (sb & 0xFF0000) >> 16; db[1] = (sb & 0x00FF00) >> 8; db[2] = sb & 0x0000FF; |
Modified tests/OFDataArrayTests.m from [4d33d1b6d0] to [742e94e327].
︙ | |||
55 56 57 58 59 60 61 | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | - - + + - + - + - - + + - + - - + + - - + - + - - - + + + - - + + - - - + + + + - + - + | TEST(@"-[count]", [array[0] count] == 2) other = (class == [OFDataArray class] ? [OFBigDataArray class] : [OFDataArray class]); TEST(@"-[isEqual:]", (array[1] = [other dataArrayWithItemSize: 4096]) && |
︙ |
Modified tests/OFSerializationTests.m from [8b60915267] to [cf7d67e102].
︙ | |||
63 64 65 66 67 68 69 | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | - - + + | [l appendObject: [OFSet setWithObjects: @"foo", @"foo", @"bar", nil]]; [l appendObject: [OFCountedSet setWithObjects: @"foo", @"foo", @"bar", nil]]; [d setObject: @"list" forKey: l]; |