Overview
Comment: | Make use of the fact that -[retain] and -[release] must not throw. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3687c35784dc81f2c007c2a9d283d7e9 |
User & Date: | js on 2011-09-10 23:54:57 |
Other Links: | manifest | tags |
Context
2011-09-11
| ||
00:03 | Make use of the fact that -[retain] and -[release] must not throw. check-in: 74eeea199c user: js tags: trunk | |
2011-09-10
| ||
23:54 | Make use of the fact that -[retain] and -[release] must not throw. check-in: 3687c35784 user: js tags: trunk | |
22:27 | Add -[removeChild:] to OFXMLElement. check-in: 4369d4c8fb user: js tags: trunk | |
Changes
Modified src/OFDictionary_hashtable.m from [2751804ef6] to [8e095b45a0].
︙ | ︙ | |||
85 86 87 88 89 90 91 | for (i = 0; i < hashtable->size; i++) data[i] = NULL; size = hashtable->size; count = hashtable->count; for (i = 0; i < size; i++) { | < | < < | < < < < < < < | 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 | for (i = 0; i < hashtable->size; i++) data[i] = NULL; size = hashtable->size; count = hashtable->count; for (i = 0; i < size; i++) { struct of_dictionary_hashtable_bucket *bucket; if (hashtable->data[i] == NULL || hashtable->data[i] == DELETED) continue; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; bucket->key = (copyKeys ? [hashtable->data[i]->key copy] : [hashtable->data[i]->key retain]); bucket->object = [hashtable->data[i]->object retain]; bucket->hash = hashtable->data[i]->hash; data[i] = bucket; } } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
177 178 179 180 181 182 183 | } if (data[i] != NULL) @throw [OFOutOfRangeException newWithClass: isa]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; | < < | < < < < | < | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | } if (data[i] != NULL) @throw [OFOutOfRangeException newWithClass: isa]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; object = [dictionary objectForKey: key]; bucket->key = [key copy]; bucket->object = [object retain]; bucket->hash = hash; data[i] = bucket; } [pool release]; } @catch (id e) { |
︙ | ︙ | |||
224 225 226 227 228 229 230 | withSize: sizeof(*data)]; size = 2; for (i = 0; i < size; i++) data[i] = NULL; i = [key hash] & 1; | < < < < < < < < | | | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | withSize: sizeof(*data)]; size = 2; for (i = 0; i < size; i++) data[i] = NULL; i = [key hash] & 1; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; bucket->key = [key copy]; bucket->object = [object retain]; bucket->hash = [key hash]; data[i] = bucket; count = 1; } @catch (id e) { [self release]; @throw e; |
︙ | ︙ | |||
325 326 327 328 329 330 331 | @throw [OFOutOfRangeException newWithClass: isa]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; key = [keysCArray[i] copy]; | < < < < < < < | < < | < < < < < | 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 | @throw [OFOutOfRangeException newWithClass: isa]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; key = [keysCArray[i] copy]; bucket->key = key; bucket->object = [objectsCArray[i] retain]; bucket->hash = hash; data[j] = bucket; continue; } /* * The key is already in the dictionary. However, we * just replace it so that the programmer gets the same * behavior as if he'd call setObject:forKey: for each * key/object pair. */ [objectsCArray[i] retain]; [data[j]->object release]; data[j]->object = objectsCArray[i]; } } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
414 415 416 417 418 419 420 | size = newSize; /* Add first key / object pair */ hash = [key hash]; j = hash & (size - 1); bucket = [self allocMemoryWithSize: sizeof(*bucket)]; | < < < < < < < < < | | | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | size = newSize; /* Add first key / object pair */ hash = [key hash]; j = hash & (size - 1); bucket = [self allocMemoryWithSize: sizeof(*bucket)]; bucket->key = [key copy]; bucket->object = [object retain]; bucket->hash = hash; data[j] = bucket; for (i = 1; i < count; i++) { uint32_t last; |
︙ | ︙ | |||
479 480 481 482 483 484 485 | if (j >= last) @throw [OFOutOfRangeException newWithClass: isa]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; | < < < < < < < < < | | < < | < < < < < | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | if (j >= last) @throw [OFOutOfRangeException newWithClass: isa]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; bucket->key = [key copy]; bucket->object = [object retain]; bucket->hash = hash; data[j] = bucket; continue; } /* * The key is already in the dictionary. However, we * just replace it so that the programmer gets the same * behavior as if he'd call setObject:forKey: for each * key/object pair. */ [object retain]; [data[j]->object release]; data[j]->object = object; count--; } } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ |
Modified src/OFMutableDictionary_hashtable.m from [ba31392df4] to [7aba881118].
︙ | ︙ | |||
155 156 157 158 159 160 161 | } if (i >= last) @throw [OFOutOfRangeException newWithClass: isa]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; | > | | | | | | | < | < < < < | < < | > | 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 | } if (i >= last) @throw [OFOutOfRangeException newWithClass: isa]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; if (copyKey) { @try { bucket->key = [key copy]; } @catch (id e) { [self freeMemory: bucket]; @throw e; } } else bucket->key = [key retain]; bucket->object = [object retain]; bucket->hash = hash; data[i] = bucket; count++; return; } old = data[i]->object; |
︙ | ︙ |
Modified src/OFStreamSelectObserver.m from [c9a34f66b3] to [ed43022176].
︙ | ︙ | |||
39 40 41 42 43 44 45 | }; @implementation OFStreamSelectObserver - init { self = [super init]; | < | | | | < < < < | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | }; @implementation OFStreamSelectObserver - init { self = [super init]; FD_ZERO(&readFDs); FD_ZERO(&writeFDs); FD_SET(cancelFD[0], &readFDs); nFDs = cancelFD[0] + 1; return self; } - (void)_addStream: (OFStream*)stream withFDSet: (fd_set*)FDSet { |
︙ | ︙ |
Modified src/OFThread.m from [28529a39cf] to [f4c5d36434].
︙ | ︙ | |||
257 258 259 260 261 262 263 | of_thread_exit(); } - initWithObject: (id)object_ { self = [super init]; | < | < < < < < | | < < < < | 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 | of_thread_exit(); } - initWithObject: (id)object_ { self = [super init]; object = [object_ retain]; return self; } #ifdef OF_HAVE_BLOCKS - initWithBlock: (of_thread_block_t)block_ { return [self initWithBlock: block_ object: nil]; } - initWithBlock: (of_thread_block_t)block_ object: (id)object_ { self = [super init]; block = [block_ retain]; object = [object_ retain]; return self; } #endif - (id)main { |
︙ | ︙ |
Modified src/OFXMLElement.m from [ddafe5133c] to [67c5a15992].
︙ | ︙ | |||
276 277 278 279 280 281 282 | if (![parser finishedParsing]) @throw [OFMalformedXMLException newWithClass: c parser: parser]; self = [delegate->element retain]; | < | < < < < | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | if (![parser finishedParsing]) @throw [OFMalformedXMLException newWithClass: c parser: parser]; self = [delegate->element retain]; [pool release]; return self; } - initWithFile: (OFString*)path { OFAutoreleasePool *pool; |
︙ | ︙ | |||
315 316 317 318 319 320 321 | if (![parser finishedParsing]) @throw [OFMalformedXMLException newWithClass: c parser: parser]; self = [delegate->element retain]; | < | < < < < | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | if (![parser finishedParsing]) @throw [OFMalformedXMLException newWithClass: c parser: parser]; self = [delegate->element retain]; [pool release]; return self; } - initWithSerialization: (OFXMLElement*)element { self = [super init]; |
︙ | ︙ | |||
423 424 425 426 427 428 429 | { return [[attributes copy] autorelease]; } - (void)setChildren: (OFArray*)children_ { OFMutableArray *new = [children_ mutableCopy]; | < < | < < < < < | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | { return [[attributes copy] autorelease]; } - (void)setChildren: (OFArray*)children_ { OFMutableArray *new = [children_ mutableCopy]; [children release]; children = new; } - (OFArray*)children { return [[children copy] autorelease]; } |
︙ | ︙ |