Differences From Artifact [74a7fa7b2d]:
- File
src/OFAutoreleasePool.m
— part of check-in
[2e484248de]
at
2011-09-22 12:09:34
on branch trunk
— Make it impossible to add objects to arbitrary autorelease pools.
This is almost never done, and was made impossible in ARC-compatible
code. (user: js, size: 4167) [annotate] [blame] [check-ins using]
To Artifact [6cfd14d520]:
- File
src/OFAutoreleasePool.m
— part of check-in
[e1e7ffa903]
at
2011-09-22 23:25:42
on branch trunk
— Exceptions are now autoreleased.
This is safe as an "exception loop" can't happen, since if allocating
an exception fails, it throws an OFAllocFailedException which is
preallocated and can always be thrown.So, the worst case would be that an autorelease of an exception fails,
triggering an OFOutOfMemoryException for which there is no memory,
resulting in an OFAllocFailedException to be thrown. (user: js, size: 4213) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
37 38 39 40 41 42 43 | #ifdef OF_THREADS + (void)initialize { if (self != [OFAutoreleasePool class]) return; if (!of_tlskey_new(&firstKey) || !of_tlskey_new(&lastKey)) | | > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #ifdef OF_THREADS + (void)initialize { if (self != [OFAutoreleasePool class]) return; if (!of_tlskey_new(&firstKey) || !of_tlskey_new(&lastKey)) @throw [OFInitializationFailedException exceptionWithClass: self]; } #endif + (void)addObject: (id)object { #ifdef OF_THREADS id lastPool = of_tlskey_get(lastKey); |
︙ | ︙ | |||
62 63 64 65 66 67 68 | #ifdef OF_THREADS lastPool = of_tlskey_get(lastKey); #endif } if (lastPool == nil) { [object release]; | | > | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | #ifdef OF_THREADS lastPool = of_tlskey_get(lastKey); #endif } if (lastPool == nil) { [object release]; @throw [OFInitializationFailedException exceptionWithClass: self]; } @try { [lastPool _addObject: object]; } @catch (id e) { [object release]; @throw e; |
︙ | ︙ | |||
93 94 95 96 97 98 99 | @try { #ifdef OF_THREADS id firstPool = of_tlskey_get(firstKey); previousPool = of_tlskey_get(lastKey); if (!of_tlskey_set(lastKey, self)) @throw [OFInitializationFailedException | | | | 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 | @try { #ifdef OF_THREADS id firstPool = of_tlskey_get(firstKey); previousPool = of_tlskey_get(lastKey); if (!of_tlskey_set(lastKey, self)) @throw [OFInitializationFailedException exceptionWithClass: isa]; #else previousPool = lastPool; lastPool = self; #endif if (firstPool == nil) { #ifdef OF_THREADS if (!of_tlskey_set(firstKey, self)) { of_tlskey_set(lastKey, previousPool); @throw [OFInitializationFailedException exceptionWithClass: isa]; } #else firstPool = self; #endif } if (previousPool != nil) |
︙ | ︙ | |||
205 206 207 208 209 210 211 | #endif [super dealloc]; } - retain { | | | | | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | #endif [super dealloc]; } - retain { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } - autorelease { @throw [OFNotImplementedException exceptionWithClass: isa selector: _cmd]; } @end |