Comment: | Rename -[allocMemoryForNItems:withSize:] and friends. It is now -[allocMemoryForNItems:ofSize:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f173477bef4f6af72ed56406937a05aa |
User & Date: | js on 2011-09-19 16:34:04 |
Other Links: | manifest | tags |
2011-09-19
| ||
16:40 | Add a few private methods to the headers to have type checking. check-in: 6a25d1d677 user: js tags: trunk | |
16:34 |
Rename -[allocMemoryForNItems:withSize:] and friends. It is now -[allocMemoryForNItems:ofSize:]. check-in: f173477bef user: js tags: trunk | |
16:22 | Make using -[tryReadLine] + OFStreamObserver safe. check-in: 535c2d5d9b user: js tags: trunk | |
Modified src/OFArray.m from [de78bb7da7] to [a34fd71e38].
︙ | |||
258 259 260 261 262 263 264 | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | - + | OFObject *container; size_t count; id *buffer; container = [[[OFObject alloc] init] autorelease]; count = [self count]; buffer = [container allocMemoryForNItems: [self count] |
︙ | |||
342 343 344 345 346 347 348 | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | - + | id *buffer; if (![self isKindOfClass: [OFMutableArray class]]) return [OFArray_subarray arrayWithArray: self range: range]; buffer = [self allocMemoryForNItems: range.length |
︙ | |||
566 567 568 569 570 571 572 | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | - + | #ifdef OF_HAVE_BLOCKS - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryForNItems: count |
︙ | |||
588 589 590 591 592 593 594 | 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | - + | } - (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block { OFArray *ret; size_t count = [self count]; id *tmp = [self allocMemoryForNItems: count |
︙ |
Modified src/OFAutoreleasePool.m from [9d07df10aa] to [5a81eccbfb].
︙ | |||
116 117 118 119 120 121 122 | 116 117 118 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 | - + - + | } if (previousPool != nil) previousPool->nextPool = self; size = GROW_SIZE; objects = [self allocMemoryForNItems: GROW_SIZE |
︙ |
Modified src/OFDataArray.m from [cb54da3d31] to [9af5fde103].
︙ | |||
252 253 254 255 256 257 258 | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | - + | - (void)addItem: (const void*)item { if (SIZE_MAX - count < 1) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data toNItems: count + 1 |
︙ | |||
275 276 277 278 279 280 281 | 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 | - + - + | fromCArray: (const void*)cArray { if (nItems > SIZE_MAX - count) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data toNItems: count + nItems |
︙ | |||
315 316 317 318 319 320 321 | 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 | - + - + - + | @throw [OFOutOfRangeException newWithClass: isa]; count -= nItems; @try { data = [self resizeMemory: data toNItems: count |
︙ | |||
527 528 529 530 531 532 533 | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | - + | lastPageByte = of_pagesize - 1; newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte; if (size != newSize) data = [self resizeMemory: data toNItems: newSize |
︙ |
Modified src/OFDictionary.m from [31ff5be5f6] to [26000249ed].
︙ | |||
307 308 309 310 311 312 313 | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | - + | return NO; } - (OFArray*)allKeys { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; id *cArray = [self allocMemoryForNItems: [self count] |
︙ | |||
337 338 339 340 341 342 343 | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | - + | return ret; } - (OFArray*)allObjects { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; id *cArray = [self allocMemoryForNItems: [self count] |
︙ |
Modified src/OFDictionary_hashtable.m from [8e095b45a0] to [a4202c2dfc].
︙ | |||
76 77 78 79 80 81 82 | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | - + | [OFMutableDictionary_hashtable class]]) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; hashtable = (OFDictionary_hashtable*)dictionary; data = [self allocMemoryForNItems: hashtable->size |
︙ | |||
134 135 136 137 138 139 140 | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | - + | for (newSize = 1; newSize < count; newSize <<= 1); if (newSize == 0) @throw [OFOutOfRangeException newWithClass: isa]; data = [self allocMemoryForNItems: newSize |
︙ | |||
200 201 202 203 204 205 206 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | - + | struct of_dictionary_hashtable_bucket *bucket; if (key == nil || object == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; data = [self allocMemoryForNItems: 2 |
︙ | |||
245 246 247 248 249 250 251 | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | - + | for (newSize = 1; newSize < count; newSize <<= 1); if (newSize == 0) @throw [OFOutOfRangeException newWithClass: isa]; data = [self allocMemoryForNItems: newSize |
︙ | |||
363 364 365 366 367 368 369 | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | - + | for (newSize = 1; newSize < count; newSize <<= 1); if (newSize == 0) @throw [OFOutOfRangeException newWithClass: isa]; data = [self allocMemoryForNItems: newSize |
︙ | |||
614 615 616 617 618 619 620 | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | - + | return NO; } - (OFArray*)allKeys { OFArray *ret; id *cArray = [self allocMemoryForNItems: count |
︙ | |||
637 638 639 640 641 642 643 | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | - + | return ret; } - (OFArray*)allObjects { OFArray *ret; id *cArray = [self allocMemoryForNItems: count |
︙ |
Modified src/OFMutableArray_adjacent.m from [dac9f5ca9a] to [fb38385e6c].
︙ | |||
150 151 152 153 154 155 156 | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | - + | id *cArray = [array cArray], *copy; size_t i, count = [array count]; if (nObjects > count) @throw [OFOutOfRangeException newWithClass: isa]; copy = [self allocMemoryForNItems: nObjects |
︙ | |||
173 174 175 176 177 178 179 | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | - + | id *cArray = [array cArray], *copy; size_t i, count = [array count]; if (range.length > count - range.start) @throw [OFOutOfRangeException newWithClass: isa]; copy = [self allocMemoryForNItems: range.length |
︙ |
Modified src/OFMutableDictionary_hashtable.m from [7aba881118] to [ae72503787].
︙ | |||
57 58 59 60 61 62 63 | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | - + | else return; if (newSize == 0) @throw [OFOutOfRangeException newWithClass: isa]; newData = [self allocMemoryForNItems: newSize |
︙ |
Modified src/OFMutableSet.m from [789db8d309] to [ca9a8cdb54].
︙ | |||
146 147 148 149 150 151 152 | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | - + | - (void)intersectSet: (OFSet*)set { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; size_t count = [self count]; id *cArray; cArray = [self allocMemoryForNItems: count |
︙ |
Modified src/OFMutableString.m from [bc1cbfd1e0] to [e446d14903].
︙ | |||
63 64 65 66 67 68 69 | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | - + | *p = t; return; } unicodeLen = [self length]; unicodeString = [self allocMemoryForNItems: unicodeLen |
︙ |
Modified src/OFObject.h from [26f6124a82] to [27e15c911a].
︙ | |||
508 509 510 511 512 513 514 | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | - + | * It will be free'd automatically when the object is deallocated. * * \param nItems The number of items to allocate * \param size The size of each item to allocate * \return A pointer to the allocated memory */ - (void*)allocMemoryForNItems: (size_t)nItems |
︙ | |||
537 538 539 540 541 542 543 | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | - + | * \param pointer A pointer to the already allocated memory * \param nItems The number of items to resize to * \param size The size of each item to resize to * \return A pointer to the resized memory chunk */ - (void*)resizeMemory: (void*)pointer toNItems: (size_t)nItems |
︙ |
Modified src/OFObject.m from [6cafb355bb] to [e5c0e6c88e].
︙ | |||
886 887 888 889 890 891 892 | 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | - + | PRE_IVAR->memoryChunks[PRE_IVAR->memoryChunksSize] = pointer; PRE_IVAR->memoryChunksSize = memoryChunksSize; return pointer; } - (void*)allocMemoryForNItems: (size_t)nItems |
︙ | |||
931 932 933 934 935 936 937 | 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 | - + - + | @throw [OFMemoryNotPartOfObjectException newWithClass: isa pointer: pointer]; } - (void*)resizeMemory: (void*)pointer toNItems: (size_t)nItems |
︙ | |||
1119 1120 1121 1122 1123 1124 1125 | 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 | - + - + | + (void*)allocMemoryWithSize: (size_t)size { @throw [OFNotImplementedException newWithClass: self selector: _cmd]; } + (void*)allocMemoryForNItems: (size_t)nItems |
︙ |
Modified src/OFStream.m from [d011dc479a] to [b36f920107].
︙ | |||
438 439 440 441 442 443 444 | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | - + | andNItems: (size_t)nItems { OFDataArray *da; char *tmp; da = [OFDataArray dataArrayWithItemSize: itemSize]; tmp = [self allocMemoryForNItems: nItems |
︙ | |||
935 936 937 938 939 940 941 | 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 | - + | #ifdef OF_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else uint16_t *tmp; tmp = [self allocMemoryForNItems: nInt16s |
︙ | |||
965 966 967 968 969 970 971 | 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | - + | #ifdef OF_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else uint32_t *tmp; tmp = [self allocMemoryForNItems: nInt32s |
︙ | |||
995 996 997 998 999 1000 1001 | 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 | - + | #ifdef OF_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else uint64_t *tmp; tmp = [self allocMemoryForNItems: nInt64s |
︙ | |||
1025 1026 1027 1028 1029 1030 1031 | 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 | - + | #ifdef OF_FLOAT_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else float *tmp; tmp = [self allocMemoryForNItems: nFloats |
︙ | |||
1055 1056 1057 1058 1059 1060 1061 | 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 | - + | #ifdef OF_FLOAT_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else double *tmp; tmp = [self allocMemoryForNItems: nDoubles |
︙ | |||
1125 1126 1127 1128 1129 1130 1131 | 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 | - + | #ifndef OF_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else uint16_t *tmp; tmp = [self allocMemoryForNItems: nInt16s |
︙ | |||
1155 1156 1157 1158 1159 1160 1161 | 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 | - + | #ifndef OF_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else uint32_t *tmp; tmp = [self allocMemoryForNItems: nInt32s |
︙ | |||
1185 1186 1187 1188 1189 1190 1191 | 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 | - + | #ifndef OF_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else uint64_t *tmp; tmp = [self allocMemoryForNItems: nInt64s |
︙ | |||
1215 1216 1217 1218 1219 1220 1221 | 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 | - + | #ifndef OF_FLOAT_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else float *tmp; tmp = [self allocMemoryForNItems: nFloats |
︙ | |||
1245 1246 1247 1248 1249 1250 1251 | 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 | - + | #ifndef OF_FLOAT_BIG_ENDIAN [self writeNBytes: size fromBuffer: buffer]; #else double *tmp; tmp = [self allocMemoryForNItems: nDoubles |
︙ |
Modified src/OFStreamObserver.m from [332048c7be] to [58de981563].
︙ | |||
125 126 127 128 129 130 131 | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | - + | &cancelAddrLen)) @throw [OFInitializationFailedException newWithClass: isa]; #endif maxFD = cancelFD[0]; FDToStream = [self allocMemoryForNItems: maxFD + 1 |
︙ | |||
281 282 283 284 285 286 287 | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | - + | int fd = [queueCArray[i] fileDescriptor]; if (fd > maxFD) { maxFD = fd; FDToStream = [self resizeMemory: FDToStream toNItems: maxFD + 1 |
︙ |
Modified src/OFString.m from [1e80f1fdb6] to [5fcda1615b].
︙ | |||
1886 1887 1888 1889 1890 1891 1892 | 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 | - + | - (of_unichar_t*)unicodeString { OFObject *object = [[[OFObject alloc] init] autorelease]; of_unichar_t *ret; size_t i, j; ret = [object allocMemoryForNItems: s->length + 2 |
︙ |