Comment: | OFDataArray: Improve API. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c85ff8d35a9a7fb28a142a4705dbbb9f |
User & Date: | js on 2012-12-15 17:52:20 |
Other Links: | manifest | tags |
2012-12-15
| ||
19:36 | OFHTTPServer: Fix handling of Host:. check-in: 2fb248a952 user: js tags: trunk | |
17:52 | OFDataArray: Improve API. check-in: c85ff8d35a user: js tags: trunk | |
2012-12-14
| ||
01:46 | Add -[description] for OFHTTPRequest(Result). check-in: c3d536d43c user: js tags: trunk | |
Modified src/OFArray_adjacent.m from [78c03c8d5c] to [72c1eebe96].
︙ | |||
107 108 109 110 111 112 113 | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | - - + + | @throw e; } @try { for (i = 0; i < count; i++) [objects[i] retain]; |
︙ | |||
144 145 146 147 148 149 150 | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | - - + + | [objects[i] retain]; } if (!ok) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; |
︙ | |||
205 206 207 208 209 210 211 | 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 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 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 | - + - + - + - + - + | - (size_t)count { return [array count]; } - (id*)objects { |
︙ | |||
303 304 305 306 307 308 309 | 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 330 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 | - + - + - + - + | otherArray = object; count = [array count]; if (count != [otherArray count]) return NO; |
Modified src/OFDataArray+Hashing.m from [d10ff72ecd] to [f44a85040b].
︙ | |||
30 31 32 33 34 35 36 | 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 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 | - + - + - + - + | { void *pool = objc_autoreleasePoolPush(); OFMD5Hash *hash = [OFMD5Hash hash]; uint8_t *digest; char cString[OF_MD5_DIGEST_SIZE * 2]; size_t i; |
Modified src/OFDataArray.h from [ebbd8162b6] to [fbee0f546e].
︙ | |||
27 28 29 30 31 32 33 | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | - + - + | * OFBigDataArray, which allocates the memory in pages rather than in bytes. * * For security reasons, serialization and deserialization is only implemented * for OFDataArrays with item size 1. */ @interface OFDataArray: OFObject <OFCopying, OFComparing, OFSerialization> { |
︙ | |||
149 150 151 152 153 154 155 | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | - + - + | * @brief Returns the size of each item in the OFDataArray in bytes. * * @return The size of each item in the OFDataArray in bytes */ - (size_t)itemSize; /*! |
︙ | |||
202 203 204 205 206 207 208 | 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 | - + - - + + - + - - - + + + | - (void)insertItem: (const void*)item atIndex: (size_t)index; /*! * @brief Adds items from a C array to the OFDataArray. * * @param count The number of items to add |
︙ |
Modified src/OFDataArray.m from [ca2bfba7fb] to [9afe18d8f2].
︙ | |||
116 117 118 119 120 121 122 | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | - - + + | char *buffer = [self allocMemoryWithSize: of_pagesize]; while (![file isAtEndOfStream]) { size_t length; length = [file readIntoBuffer: buffer length: of_pagesize]; |
︙ | |||
183 184 185 186 187 188 189 | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | - + | if (count & 1) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; count >>= 1; cString = [string UTF8String]; |
︙ | |||
210 211 212 213 214 215 216 | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | - + | byte |= c2 - 'a' + 10; else if (c2 >= 'A' && c2 <= 'F') byte |= c2 - 'A' + 10; else @throw [OFInvalidFormatException exceptionWithClass: [self class]]; |
︙ | |||
286 287 288 289 290 291 292 | 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 330 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 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | - + - + - + - + - + - + - + - - - + + + - + - - - + + + - - + + - + - - - + + + - - + + - - - + + + - + - - - + + + - + - + - + - - + + - - - + + + - - - + + + - + - + - - + + - + | } - (size_t)itemSize { return itemSize; } |
︙ | |||
465 466 467 468 469 470 471 | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | - + | @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; otherCount = [otherDataArray count]; minimumCount = (count > otherCount ? otherCount : count); |
︙ | |||
488 489 490 491 492 493 494 | 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 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | - + - + - + - + - + - + | { uint32_t hash; size_t i; OF_HASH_INIT(hash); for (i = 0; i < count * itemSize; i++) |
︙ | |||
583 584 585 586 587 588 589 | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | - - + + - + - - + + - + - + - - + + - + - + - - - + + + - - + + - + - - + + - + - + - + - - + + - - + + - - + + - + - + | if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; lastPageByte = of_pagesize - 1; newSize = ((count + 1) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) |
Modified src/OFHTTPClient.m from [befaf122bc] to [9d0e6d26b7].
︙ | |||
215 216 217 218 219 220 221 | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | - + | [sock writeString: @"\r\n"]; /* Work around a bug in lighttpd, see above */ [sock flushWriteBuffer]; [sock setWriteBufferEnabled: NO]; if (requestType == OF_HTTP_REQUEST_TYPE_POST) |
︙ | |||
403 404 405 406 407 408 409 | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | - - + + | length: length request: request]; objc_autoreleasePoolPop(pool2); pool2 = objc_autoreleasePoolPush(); bytesReceived += length; |
︙ | |||
441 442 443 444 445 446 447 | 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | - - + + | didReceiveData: buffer length: length request: request]; objc_autoreleasePoolPop(pool2); bytesReceived += length; |
︙ |
Modified src/OFHTTPServer.m from [e6f92f7b1d] to [61524a3f46].
︙ | |||
396 397 398 399 400 401 402 | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | - - + + | didReadIntoBuffer: (const char*)buffer length: (size_t)length exception: (OFException*)exception { if ([sock_ isAtEndOfStream] || exception != nil) return NO; |
︙ | |||
497 498 499 500 501 502 503 | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | - + | while ((key = [keyEnumerator nextObject]) != nil && (value = [valueEnumerator nextObject]) != nil) [sock writeFormat: @"%@: %@\r\n", key, value]; [sock writeString: @"\r\n"]; if (requestType != OF_HTTP_REQUEST_TYPE_HEAD) |
︙ |
Modified src/OFMD5Hash.h from [b8a9b23fd3] to [569dd9f1c4].
︙ | |||
12 13 14 15 16 17 18 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | - + | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFHash.h" |
︙ |
Modified src/OFMutableArray_adjacent.m from [b75900fe79] to [f345fceab0].
︙ | |||
61 62 63 64 65 66 67 | 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 | - - - + + + - + | - (void)insertObjectsFromArray: (OFArray*)array_ atIndex: (size_t)index { id *objects = [array_ objects]; size_t i, count = [array_ count]; |
︙ | |||
105 106 107 108 109 110 111 | 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 136 137 138 139 | - + - + | id *objects; id oldObject; if (object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; |
︙ | |||
148 149 150 151 152 153 154 | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | - + | id *objects; size_t i, count; if (object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; |
︙ | |||
174 175 176 177 178 179 180 | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | - + | id *objects; size_t i, count; if (object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; |
︙ | |||
200 201 202 203 204 205 206 | 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 | - + - + | [object release]; mutations++; } - (void)removeAllObjects { |
︙ | |||
251 252 253 254 255 256 257 | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | - + - + | mutations++; } - (void)exchangeObjectAtIndex: (size_t)index1 withObjectAtIndex: (size_t)index2 { |
︙ | |||
306 307 308 309 310 311 312 | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | - + - + | initWithArray: self mutationsPtr: &mutations] autorelease]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { |
︙ |
Modified src/OFStream.m from [cea01024de] to [c1d9e7762b].
︙ | |||
496 497 498 499 500 501 502 | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | - - + + | tmp = [self allocMemoryWithSize: itemSize count: count]; @try { [self readIntoBuffer: tmp exactLength: count * itemSize]; |
︙ | |||
519 520 521 522 523 524 525 | 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | - - + + | @try { while (![self isAtEndOfStream]) { size_t length; length = [self readIntoBuffer: buffer length: of_pagesize]; |
︙ | |||
1353 1354 1355 1356 1357 1358 1359 | 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 | - + - + | return size; } - (size_t)writeDataArray: (OFDataArray*)dataArray { size_t length = [dataArray count] * [dataArray itemSize]; |
︙ |
Modified src/OFStreamObserver.m from [f18e106529] to [0c778cd456].
︙ | |||
289 290 291 292 293 294 295 | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | - - + + - - + + | } - (void)OF_processQueue { [mutex lock]; @try { OFStream **queueObjects = [queue objects]; |
︙ |
Modified src/OFStreamObserver_kqueue.m from [1e1bf29b71] to [c9bbb01ae1].
︙ | |||
120 121 122 123 124 125 126 | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | - + | if ([self OF_processCache]) { objc_autoreleasePoolPop(pool); return YES; } objc_autoreleasePoolPop(pool); |
︙ |
Modified src/OFStreamObserver_poll.m from [ca9d956364] to [c07acfe92a].
︙ | |||
56 57 58 59 60 61 62 | 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 | - + - - + + - + - - + + - + | [super dealloc]; } - (void)OF_addFileDescriptor: (int)fd withEvents: (short)events { |
︙ | |||
119 120 121 122 123 124 125 | 119 120 121 122 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 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 | - + - + - + - - + + - + - + - + - + - + - + - + | [self OF_removeFileDescriptor: fd withEvents: POLLOUT]; } - (BOOL)observeWithTimeout: (double)timeout { void *pool = objc_autoreleasePoolPush(); |
Modified src/OFString.m from [90ef2353c5] to [712053e8f6].
︙ | |||
779 780 781 782 783 784 785 | 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | - + | if ([contentType hasSuffix: @"charset=windows-1252"]) encoding = OF_STRING_ENCODING_WINDOWS_1252; } if (encoding == OF_STRING_ENCODING_AUTODETECT) encoding = OF_STRING_ENCODING_UTF_8; |
︙ |
Modified src/OFXMLElement.m from [177c46b1d0] to [16ca049b3f].
︙ | |||
636 637 638 639 640 641 642 | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | - - + + - + | indentation: ind level: level + 1]; else child = [childrenObjects[j] XMLStringWithIndentation: ind level: level + 1]; |
︙ |
Modified src/OFXMLParser.m from [c33143cf90] to [4543342dd4].
︙ | |||
43 44 45 46 47 48 49 | 43 44 45 46 47 48 49 50 51 52 53 54 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 | - - + + - - + + - + - + - - + + - + - - + + - + | 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)) |
︙ | |||
533 534 535 536 537 538 539 | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | - + | return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); pool = objc_autoreleasePoolPush(); |
︙ | |||
616 617 618 619 620 621 622 | 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 | - + | return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); pool = objc_autoreleasePoolPush(); |
︙ | |||
759 760 761 762 763 764 765 | 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 | - + | return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); pool = objc_autoreleasePoolPush(); |
︙ |
Modified src/base64.m from [9c1fb17538] to [c2598ccd38].
︙ | |||
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 [eae28a70a3] to [6c7d01470b].
︙ | |||
57 58 59 60 61 62 63 | 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 | - - + + - - + + - + - + - - - - - + + + + + - + - - - + + + - + - - - + + | 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 [cf7d67e102] to [61f9a15e64].
︙ | |||
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]; |