Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Continue migrating to the ARC functions for RR |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
054dd2bfda938e9b32fb7a2351bb94aa |
| User & Date: | js 2025-04-13 23:26:53.008 |
Context
|
2025-04-14
| ||
| 21:10 | Continue migrating to the ARC functions for RR check-in: 8ad878075b user: js tags: trunk | |
|
2025-04-13
| ||
| 23:26 | Continue migrating to the ARC functions for RR check-in: 054dd2bfda user: js tags: trunk | |
| 23:01 | Continue migrating to the ARC functions for RR check-in: b0a3da90ad user: js tags: trunk | |
Changes
Changes to src/OFMutex.m.
| ︙ | ︙ | |||
30 31 32 33 34 35 36 |
#import "OFUnlockFailedException.h"
@implementation OFMutex
@synthesize name = _name;
+ (instancetype)mutex
{
| | | | | 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 |
#import "OFUnlockFailedException.h"
@implementation OFMutex
@synthesize name = _name;
+ (instancetype)mutex
{
return objc_autoreleaseReturnValue([[self alloc] init]);
}
- (instancetype)init
{
self = [super init];
if (OFPlainMutexNew(&_mutex) != 0) {
Class c = self.class;
objc_release(self);
@throw [OFInitializationFailedException exceptionWithClass: c];
}
_initialized = true;
return self;
}
- (void)dealloc
{
if (_initialized) {
int error = OFPlainMutexFree(&_mutex);
if (error != 0) {
OFEnsure(error == EBUSY);
@throw [OFStillLockedException exceptionWithLock: self];
}
}
objc_release(_name);
[super dealloc];
}
- (void)lock
{
int error = OFPlainMutexLock(&_mutex);
|
| ︙ | ︙ |
Changes to src/OFNSDNSResourceRecord.m.
| ︙ | ︙ | |||
41 42 43 44 45 46 47 |
DNSClass: DNSClass
recordType: OFDNSRecordTypeNS
TTL: TTL];
@try {
_authoritativeHost = [authoritativeHost copy];
} @catch (id e) {
| | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
DNSClass: DNSClass
recordType: OFDNSRecordTypeNS
TTL: TTL];
@try {
_authoritativeHost = [authoritativeHost copy];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
objc_release(_authoritativeHost);
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFNSDNSResourceRecord *record;
|
| ︙ | ︙ |
Changes to src/OFNotification.m.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 |
@implementation OFNotification
@synthesize name = _name, object = _object, userInfo = _userInfo;
+ (instancetype)notificationWithName: (OFNotificationName)name
object: (id)object
{
| | > > | | | | | | | | | | | | 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 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 |
@implementation OFNotification
@synthesize name = _name, object = _object, userInfo = _userInfo;
+ (instancetype)notificationWithName: (OFNotificationName)name
object: (id)object
{
return objc_autoreleaseReturnValue([[self alloc] initWithName: name
object: object]);
}
+ (instancetype)notificationWithName: (OFNotificationName)name
object: (id)object
userInfo: (OFDictionary *)userInfo
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithName: name
object: object
userInfo: userInfo]);
}
- (instancetype)initWithName: (OFNotificationName)name object: (id)object
{
return [self initWithName: name object: object userInfo: nil];
}
- (instancetype)initWithName: (OFNotificationName)name
object: (id)object
userInfo: (OFDictionary *)userInfo
{
self = [super init];
@try {
_name = [name copy];
_object = objc_retain(object);
_userInfo = [userInfo copy];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
objc_release(_name);
objc_release(_object);
objc_release(_userInfo);
[super dealloc];
}
- (id)copy
{
return objc_retain(self);
}
- (OFString *)description
{
void *pool = objc_autoreleasePoolPush();
OFString *object = [[_object description]
stringByReplacingOccurrencesOfString: @"\n"
withString: @"\n\t"];
OFString *userInfo = [_userInfo.description
stringByReplacingOccurrencesOfString: @"\n"
withString: @"\n\t"];
OFString *ret = [OFString stringWithFormat:
@"<%@:\n"
@"\tName = %@\n"
@"\tObject = %@\n"
@"\tUser info = %@\n"
@">",
self.class, _name, object, userInfo];
objc_retain(ret);
objc_autoreleasePoolPop(pool);
return objc_autoreleaseReturnValue(ret);
}
@end
|
Changes to src/OFNotificationCenter.m.
| ︙ | ︙ | |||
68 69 70 71 72 73 74 |
@try {
void *pool = objc_autoreleasePoolPush();
_name = [name copy];
_observer = observer;
_selector = selector;
| | | | | | | | | 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 |
@try {
void *pool = objc_autoreleasePoolPush();
_name = [name copy];
_observer = observer;
_selector = selector;
_object = objc_retain(object);
_selectorHash = [[OFString stringWithUTF8String:
sel_getName(_selector)] hash];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
#ifdef OF_HAVE_BLOCKS
- (instancetype)initWithName: (OFNotificationName)name
object: (id)object
block: (OFNotificationCenterBlock)block
{
self = [super init];
@try {
_name = [name copy];
_object = objc_retain(object);
_block = [block copy];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
#endif
- (void)dealloc
{
objc_release(_name);
objc_release(_object);
#ifdef OF_HAVE_BLOCKS
objc_release(_block);
#endif
[super dealloc];
}
- (bool)isEqual: (OFNotificationCenterHandle *)handle
{
|
| ︙ | ︙ | |||
182 183 184 185 186 187 188 |
- (instancetype)init
{
self = [super init];
@try {
_handles = [[OFMutableDictionary alloc] init];
} @catch (id e) {
| | | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
- (instancetype)init
{
self = [super init];
@try {
_handles = [[OFMutableDictionary alloc] init];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
objc_release(_handles);
[super dealloc];
}
- (void)of_addObserver: (OFNotificationCenterHandle *)handle
{
@synchronized (_handles) {
|
| ︙ | ︙ | |||
219 220 221 222 223 224 225 |
- (void)addObserver: (id)observer
selector: (SEL)selector
name: (OFNotificationName)name
object: (id)object
{
void *pool = objc_autoreleasePoolPush();
| | | | | | < | | | | < | | | > | | | < | 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 293 294 295 296 297 298 299 300 301 302 |
- (void)addObserver: (id)observer
selector: (SEL)selector
name: (OFNotificationName)name
object: (id)object
{
void *pool = objc_autoreleasePoolPush();
[self of_addObserver: objc_autorelease(
[[OFNotificationCenterHandle alloc] initWithName: name
observer: observer
selector: selector
object: object])];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_BLOCKS
- (id)addObserverForName: (OFNotificationName)name
object: (id)object
usingBlock: (OFNotificationCenterBlock)block
{
void *pool = objc_autoreleasePoolPush();
OFNotificationCenterHandle *handle = objc_autorelease(
[[OFNotificationCenterHandle alloc] initWithName: name
object: object
block: block]);
[self of_addObserver: handle];
objc_retain(handle);
objc_autoreleasePoolPop(pool);
return objc_autoreleaseReturnValue(handle);
}
#endif
- (void)removeObserver: (id)handle_
{
OFNotificationCenterHandle *handle;
void *pool;
if (![handle_ isKindOfClass: [OFNotificationCenterHandle class]])
@throw [OFInvalidArgumentException exception];
handle = handle_;
pool = objc_autoreleasePoolPush();
if (![handle isKindOfClass: [OFNotificationCenterHandle class]])
@throw [OFInvalidArgumentException exception];
@synchronized (_handles) {
OFNotificationName name =
objc_autorelease([handle->_name copy]);
OFMutableSet *handlesForName = [_handles objectForKey: name];
[handlesForName removeObject: handle];
if (handlesForName.count == 0)
[_handles removeObjectForKey: name];
}
objc_autoreleasePoolPop(pool);
}
- (void)removeObserver: (id)observer
selector: (SEL)selector
name: (OFNotificationName)name
object: (id)object
{
void *pool = objc_autoreleasePoolPush();
[self removeObserver: objc_autorelease(
[[OFNotificationCenterHandle alloc] initWithName: name
observer: observer
selector: selector
object: object])];
objc_autoreleasePoolPop(pool);
}
- (void)postNotification: (OFNotification *)notification
{
void *pool = objc_autoreleasePoolPush();
|
| ︙ | ︙ |
Changes to src/OFNumber.m.
| ︙ | ︙ | |||
391 392 393 394 395 396 397 |
+ (instancetype)valueWithRect: (OFRect)rect
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)numberWithBool: (bool)value
{
| | | | | | > | > | > | > | > | > | | > | | 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 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
+ (instancetype)valueWithRect: (OFRect)rect
{
OF_UNRECOGNIZED_SELECTOR
}
+ (instancetype)numberWithBool: (bool)value
{
return objc_autoreleaseReturnValue([[self alloc] initWithBool: value]);
}
+ (instancetype)numberWithChar: (signed char)value
{
return objc_autoreleaseReturnValue([[self alloc] initWithChar: value]);
}
+ (instancetype)numberWithShort: (short)value
{
return objc_autoreleaseReturnValue([[self alloc] initWithShort: value]);
}
+ (instancetype)numberWithInt: (int)value
{
return objc_autoreleaseReturnValue([[self alloc] initWithInt: value]);
}
+ (instancetype)numberWithLong: (long)value
{
return objc_autoreleaseReturnValue([[self alloc] initWithLong: value]);
}
+ (instancetype)numberWithLongLong: (long long)value
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithLongLong: value]);
}
+ (instancetype)numberWithUnsignedChar: (unsigned char)value
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithUnsignedChar: value]);
}
+ (instancetype)numberWithUnsignedShort: (unsigned short)value
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithUnsignedShort: value]);
}
+ (instancetype)numberWithUnsignedInt: (unsigned int)value
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithUnsignedInt: value]);
}
+ (instancetype)numberWithUnsignedLong: (unsigned long)value
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithUnsignedLong: value]);
}
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)value
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithUnsignedLongLong: value]);
}
+ (instancetype)numberWithFloat: (float)value
{
return objc_autoreleaseReturnValue([[self alloc] initWithFloat: value]);
}
+ (instancetype)numberWithDouble: (double)value
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithDouble: value]);
}
- (instancetype)initWithBool: (bool)value
{
return [self initWithBytes: &value objCType: @encode(bool)];
}
|
| ︙ | ︙ | |||
726 727 728 729 730 731 732 |
OFHashFinalize(&hash);
return hash;
}
- (id)copy
{
| | | 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
OFHashFinalize(&hash);
return hash;
}
- (id)copy
{
return objc_retain(self);
}
- (OFString *)description
{
return [self stringValue];
}
|
| ︙ | ︙ |
Changes to src/OFObject+KeyValueCoding.m.
| ︙ | ︙ | |||
115 116 117 118 119 120 121 |
CASE('d', double, numberWithDouble:)
#undef CASE
default:
objc_autoreleasePoolPop(pool);
return [self valueForUndefinedKey: key];
}
| | | | | | 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 140 141 142 143 144 145 146 147 148 |
CASE('d', double, numberWithDouble:)
#undef CASE
default:
objc_autoreleasePoolPop(pool);
return [self valueForUndefinedKey: key];
}
objc_retain(ret);
objc_autoreleasePoolPop(pool);
return objc_autoreleaseReturnValue(ret);
}
- (id)valueForKeyPath: (OFString *)keyPath
{
void *pool = objc_autoreleasePoolPush();
id ret = self;
for (OFString *key in [keyPath componentsSeparatedByString: @"."])
ret = [ret valueForKey: key];
objc_retain(ret);
objc_autoreleasePoolPop(pool);
return objc_autoreleaseReturnValue(ret);
}
- (id)valueForUndefinedKey: (OFString *)key
{
@throw [OFUndefinedKeyException exceptionWithObject: self key: key];
}
|
| ︙ | ︙ |
Changes to src/OFObject.h.
| ︙ | ︙ | |||
1080 1081 1082 1083 1084 1085 1086 |
* Derived classes may override this, but need to use the following pattern:
* @code
* self = [super init];
*
* @try {
* // Custom initialization code goes here.
* } @catch (id e) {
| | | 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 |
* Derived classes may override this, but need to use the following pattern:
* @code
* self = [super init];
*
* @try {
* // Custom initialization code goes here.
* } @catch (id e) {
* objc_release(self);
* @throw e;
* }
*
* return self;
* @endcode
*
* With ARC enabled, the following pattern needs to be used instead:
|
| ︙ | ︙ |
Changes to src/OFOptionsParser.m.
| ︙ | ︙ | |||
40 41 42 43 44 45 46 |
@implementation OFOptionsParser
@synthesize lastOption = _lastOption, lastLongOption = _lastLongOption;
@synthesize argument = _argument;
+ (instancetype)parserWithOptions: (const OFOptionsParserOption *)options
{
| > | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
@implementation OFOptionsParser
@synthesize lastOption = _lastOption, lastLongOption = _lastLongOption;
@synthesize argument = _argument;
+ (instancetype)parserWithOptions: (const OFOptionsParserOption *)options
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithOptions: options]);
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
| ︙ | ︙ | |||
117 118 119 120 121 122 123 |
setObject: iter2
forKey: iter2->longOption];
} @catch (id e) {
/*
* Make sure we are in a consistent
* state where dealloc works.
*/
| | | | | | | | | | | 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 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 |
setObject: iter2
forKey: iter2->longOption];
} @catch (id e) {
/*
* Make sure we are in a consistent
* state where dealloc works.
*/
objc_release(iter2->longOption);
iter2->shortOption = '\0';
iter2->longOption = nil;
@throw e;
}
}
}
iter2->shortOption = '\0';
iter2->longOption = nil;
_arguments = objc_retain([OFApplication arguments]);
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
if (_options != NULL)
for (OFOptionsParserOption *iter = _options;
iter->shortOption != '\0' || iter->longOption != nil;
iter++)
objc_release(iter->longOption);
OFFreeMemory(_options);
objc_release(_longOptions);
objc_release(_arguments);
objc_release(_argument);
[super dealloc];
}
- (OFUnichar)nextOption
{
OFOptionsParserOption *iter;
OFString *argument;
if (_done || _index >= _arguments.count)
return '\0';
objc_release(_lastLongOption);
objc_release(_argument);
_lastLongOption = nil;
_argument = nil;
argument = [_arguments objectAtIndex: _index];
if (_subIndex == 0) {
if (argument.length < 2 ||
|
| ︙ | ︙ | |||
216 217 218 219 220 221 222 | if (option->hasArgument == 0 && _argument != nil) return '='; if (option->isSpecifiedPtr != NULL) *option->isSpecifiedPtr = true; if (option->argumentPtr != NULL) *option->argumentPtr = | | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | if (option->hasArgument == 0 && _argument != nil) return '='; if (option->isSpecifiedPtr != NULL) *option->isSpecifiedPtr = true; if (option->argumentPtr != NULL) *option->argumentPtr = objc_autorelease([_argument copy]); if (option->shortOption != '\0') _lastOption = option->shortOption; return _lastOption; } |
| ︙ | ︙ | |||
256 257 258 259 260 261 262 | _argument = [argument copy]; if (iter->isSpecifiedPtr != NULL) *iter->isSpecifiedPtr = true; if (iter->argumentPtr != NULL) *iter->argumentPtr = | | | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | _argument = [argument copy]; if (iter->isSpecifiedPtr != NULL) *iter->isSpecifiedPtr = true; if (iter->argumentPtr != NULL) *iter->argumentPtr = objc_autorelease([_argument copy]); _index++; _subIndex = 0; return _lastOption; } } |
| ︙ | ︙ |
Changes to src/OFPTRDNSResourceRecord.m.
| ︙ | ︙ | |||
41 42 43 44 45 46 47 |
DNSClass: DNSClass
recordType: OFDNSRecordTypePTR
TTL: TTL];
@try {
_domainName = [domainName copy];
} @catch (id e) {
| | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
DNSClass: DNSClass
recordType: OFDNSRecordTypePTR
TTL: TTL];
@try {
_domainName = [domainName copy];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
objc_release(_domainName);
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFPTRDNSResourceRecord *record;
|
| ︙ | ︙ |
Changes to src/OFPair.m.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 |
#import "OFPair.h"
#import "OFString.h"
@implementation OFPair
+ (instancetype)pairWithFirstObject: (id)firstObject
secondObject: (id)secondObject
{
| > | | | | | | | | 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 59 60 |
#import "OFPair.h"
#import "OFString.h"
@implementation OFPair
+ (instancetype)pairWithFirstObject: (id)firstObject
secondObject: (id)secondObject
{
return objc_autoreleaseReturnValue(
[[self alloc] initWithFirstObject: firstObject
secondObject: secondObject]);
}
- (instancetype)initWithFirstObject: (id)firstObject
secondObject: (id)secondObject
{
self = [super init];
@try {
_firstObject = objc_retain(firstObject);
_secondObject = objc_retain(secondObject);
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
objc_release(_firstObject);
objc_release(_secondObject);
[super dealloc];
}
- (id)firstObject
{
return _firstObject;
|
| ︙ | ︙ | |||
99 100 101 102 103 104 105 |
OFHashFinalize(&hash);
return hash;
}
- (id)copy
{
| | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
OFHashFinalize(&hash);
return hash;
}
- (id)copy
{
return objc_retain(self);
}
- (id)mutableCopy
{
return [[OFMutablePair alloc] initWithFirstObject: _firstObject
secondObject: _secondObject];
}
|
| ︙ | ︙ |
Changes to src/OFPlugin.m.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 |
#import "OFPlugin.h"
#import "OFLoadPluginFailedException.h"
@implementation OFPlugin
+ (instancetype)pluginWithPath: (OFString *)path
{
| | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#import "OFPlugin.h"
#import "OFLoadPluginFailedException.h"
@implementation OFPlugin
+ (instancetype)pluginWithPath: (OFString *)path
{
return objc_autoreleaseReturnValue([[self alloc] initWithPath: path]);
}
+ (OFString *)pathForName: (OFString *)name
{
return [self pathForPluginWithName: name];
}
|
| ︙ | ︙ |
Changes to src/OFPollKernelEventObserver.m.
| ︙ | ︙ | |||
49 50 51 52 53 54 55 |
_FDs = [[OFMutableData alloc] initWithItemSize:
sizeof(struct pollfd)];
[_FDs addItem: &p];
_maxFD = _cancelFD[0];
_FDToObject = OFAllocMemory((size_t)_maxFD + 1, sizeof(id));
} @catch (id e) {
| | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
_FDs = [[OFMutableData alloc] initWithItemSize:
sizeof(struct pollfd)];
[_FDs addItem: &p];
_maxFD = _cancelFD[0];
_FDToObject = OFAllocMemory((size_t)_maxFD + 1, sizeof(id));
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
objc_release(_FDs);
OFFreeMemory(_FDToObject);
[super dealloc];
}
static void
addObject(OFPollKernelEventObserver *self, id object, int fd, short events)
|
| ︙ | ︙ | |||
172 173 174 175 176 177 178 | size_t nFDs; if ([self processReadBuffers]) return; pool = objc_autoreleasePoolPush(); | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | size_t nFDs; if ([self processReadBuffers]) return; pool = objc_autoreleasePoolPush(); FDs = [objc_autorelease([_FDs mutableCopy]) mutableItems]; nFDs = _FDs.count; #ifdef OPEN_MAX if (nFDs > OPEN_MAX) @throw [OFOutOfRangeException exception]; #endif |
| ︙ | ︙ |
Changes to src/OFRIPEMD160Hash.m.
| ︙ | ︙ | |||
152 153 154 155 156 157 158 |
+ (size_t)blockSize
{
return blockSize;
}
+ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
| | | | | | 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 192 193 194 195 196 197 198 199 200 201 202 |
+ (size_t)blockSize
{
return blockSize;
}
+ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
return objc_autoreleaseReturnValue([[self alloc]
initWithAllowsSwappableMemory: allowsSwappableMemory]);
}
- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
self = [super init];
@try {
_iVarsData = [[OFSecureData alloc]
initWithCount: sizeof(*_iVars)
allowsSwappableMemory: allowsSwappableMemory];
_iVars = _iVarsData.mutableItems;
_allowsSwappableMemory = allowsSwappableMemory;
[self of_resetState];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)of_init
{
return [super init];
}
- (void)dealloc
{
objc_release(_iVarsData);
[super dealloc];
}
- (size_t)digestSize
{
return digestSize;
|
| ︙ | ︙ |
Changes to src/OFRPDNSResourceRecord.m.
| ︙ | ︙ | |||
43 44 45 46 47 48 49 |
recordType: OFDNSRecordTypeRP
TTL: TTL];
@try {
_mailbox = [mailbox copy];
_TXTDomainName = [TXTDomainName copy];
} @catch (id e) {
| | | | | 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 |
recordType: OFDNSRecordTypeRP
TTL: TTL];
@try {
_mailbox = [mailbox copy];
_TXTDomainName = [TXTDomainName copy];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
objc_release(_mailbox);
objc_release(_TXTDomainName);
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFRPDNSResourceRecord *record;
|
| ︙ | ︙ |
Changes to src/OFRangeCharacterSet.m.
| ︙ | ︙ | |||
36 37 38 39 40 41 42 |
@try {
if (SIZE_MAX - range.location < range.length)
@throw [OFOutOfRangeException exception];
_range = range;
} @catch (id e) {
| | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
@try {
if (SIZE_MAX - range.location < range.length)
@throw [OFOutOfRangeException exception];
_range = range;
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (bool)characterIsMember: (OFUnichar)character
|
| ︙ | ︙ |
Changes to src/OFRecursiveMutex.m.
| ︙ | ︙ | |||
30 31 32 33 34 35 36 |
#import "OFUnlockFailedException.h"
@implementation OFRecursiveMutex
@synthesize name = _name;
+ (instancetype)mutex
{
| | | | | 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 |
#import "OFUnlockFailedException.h"
@implementation OFRecursiveMutex
@synthesize name = _name;
+ (instancetype)mutex
{
return objc_autoreleaseReturnValue([[self alloc] init]);
}
- (instancetype)init
{
self = [super init];
if (OFPlainRecursiveMutexNew(&_rmutex) != 0) {
Class c = self.class;
objc_release(self);
@throw [OFInitializationFailedException exceptionWithClass: c];
}
_initialized = true;
return self;
}
- (void)dealloc
{
if (_initialized) {
int error = OFPlainRecursiveMutexFree(&_rmutex);
if (error != 0) {
OFEnsure(error == EBUSY);
@throw [OFStillLockedException exceptionWithLock: self];
}
}
objc_release(_name);
[super dealloc];
}
- (void)lock
{
int error = OFPlainRecursiveMutexLock(&_rmutex);
|
| ︙ | ︙ |
Changes to src/OFRunLoop.m.
| ︙ | ︙ | |||
278 279 280 281 282 283 284 |
_execSignalsSelectors = [[OFMutableData alloc]
initWithItemSize: sizeof(SEL)];
# ifdef OF_HAVE_THREADS
_execSignalsMutex = [[OFMutex alloc] init];
# endif
#endif
} @catch (id e) {
| | | | | | | | | | | | | > | < | | > | < | | 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 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 |
_execSignalsSelectors = [[OFMutableData alloc]
initWithItemSize: sizeof(SEL)];
# ifdef OF_HAVE_THREADS
_execSignalsMutex = [[OFMutex alloc] init];
# endif
#endif
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
objc_release(_timersQueue);
#ifdef OF_HAVE_THREADS
objc_release(_timersQueueMutex);
#endif
#ifdef OF_HAVE_SOCKETS
objc_release(_kernelEventObserver);
objc_release(_readQueues);
objc_release(_writeQueues);
#endif
#ifdef OF_HAVE_THREADS
objc_release(_condition);
#endif
#ifdef OF_AMIGAOS
objc_release(_execSignals);
objc_release(_execSignalsTargets);
objc_release(_execSignalsSelectors);
# ifdef OF_HAVE_THREADS
objc_release(_execSignalsMutex);
# endif
#endif
[super dealloc];
}
#ifdef OF_HAVE_SOCKETS
- (void)objectIsReadyForReading: (id)object
{
/*
* Retain the queue so that it doesn't disappear from us because the
* handler called -[cancelAsyncRequests].
*/
OFList OF_GENERIC(OF_KINDOF(OFRunLoopReadQueueItem *)) *queue =
objc_retain([_readQueues objectForKey: object]);
OFAssert(queue != nil);
@try {
if (![queue.firstObject handleObject: object]) {
OFListItem listItem = queue.firstListItem;
/*
* The handler might have called -[cancelAsyncRequests]
* so that our queue is now empty, in which case we
* should do nothing.
*/
if (listItem != NULL) {
/*
* Make sure we keep the target until after we
* are done removing the object. The reason for
* this is that the target might call
* -[cancelAsyncRequests] in its dealloc.
*/
objc_autorelease(objc_retain(
OFListItemObject(listItem)));
[queue removeListItem: listItem];
if (queue.count == 0) {
[_kernelEventObserver
removeObjectForReading: object];
[_readQueues
removeObjectForKey: object];
}
}
}
} @finally {
objc_release(queue);
}
}
- (void)objectIsReadyForWriting: (id)object
{
/*
* Retain the queue so that it doesn't disappear from us because the
* handler called -[cancelAsyncRequests].
*/
OFList *queue = objc_retain([_writeQueues objectForKey: object]);
OFAssert(queue != nil);
@try {
if (![queue.firstObject handleObject: object]) {
OFListItem listItem = queue.firstListItem;
/*
* The handler might have called -[cancelAsyncRequests]
* so that our queue is now empty, in which case we
* should do nothing.
*/
if (listItem != NULL) {
/*
* Make sure we keep the target until after we
* are done removing the object. The reason for
* this is that the target might call
* -[cancelAsyncRequests] in its dealloc.
*/
objc_autorelease(objc_retain(
OFListItemObject(listItem)));
[queue removeListItem: listItem];
if (queue.count == 0) {
[_kernelEventObserver
removeObjectForWriting: object];
[_writeQueues
removeObjectForKey: object];
}
}
}
} @finally {
objc_release(queue);
}
}
#endif
#ifdef OF_AMIGAOS
- (void)execSignalWasReceived: (ULONG)signalMask
{
|
| ︙ | ︙ | |||
422 423 424 425 426 427 428 |
[_execSignalsMutex lock];
@try {
# endif
/*
* Create copies, so that signal handlers are allowed to modify
* signals.
*/
| | | | | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
[_execSignalsMutex lock];
@try {
# endif
/*
* Create copies, so that signal handlers are allowed to modify
* signals.
*/
signals = objc_autorelease([_execSignals copy]);
targets = objc_autorelease([_execSignalsTargets copy]);
selectors = objc_autorelease([_execSignalsSelectors copy]);
# ifdef OF_HAVE_THREADS
} @finally {
[_execSignalsMutex unlock];
}
# endif
signalsItems = signals.items;
|
| ︙ | ︙ | |||
461 462 463 464 465 466 467 |
- (bool)handleObject: (id)object
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)dealloc
{
| | | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
- (bool)handleObject: (id)object
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)dealloc
{
objc_release(_delegate);
[super dealloc];
}
@end
@implementation OFRunLoopReadQueueItem
- (bool)handleObject: (id)object
|
| ︙ | ︙ | |||
501 502 503 504 505 506 507 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
| | | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
objc_release(_handler);
[super dealloc];
}
# endif
@end
@implementation OFRunLoopExactReadQueueItem
|
| ︙ | ︙ | |||
557 558 559 560 561 562 563 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
| | | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
objc_release(_handler);
[super dealloc];
}
# endif
@end
@implementation OFRunLoopReadStringQueueItem
|
| ︙ | ︙ | |||
600 601 602 603 604 605 606 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
| | | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
objc_release(_handler);
[super dealloc];
}
# endif
@end
@implementation OFRunLoopReadLineQueueItem
|
| ︙ | ︙ | |||
643 644 645 646 647 648 649 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
| | | 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
objc_release(_handler);
[super dealloc];
}
# endif
@end
@implementation OFRunLoopWriteDataQueueItem
|
| ︙ | ︙ | |||
687 688 689 690 691 692 693 | newData = _handler(object, _data, _writtenLength, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; | | | | | | 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
newData = _handler(object, _data, _writtenLength, exception);
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
objc_release(oldData);
_writtenLength = 0;
return true;
} else {
# endif
if (![_delegate respondsToSelector:
@selector(stream:didWriteData:bytesWritten:exception:)])
return false;
newData = [_delegate stream: object
didWriteData: _data
bytesWritten: _writtenLength
exception: exception];
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
objc_release(oldData);
_writtenLength = 0;
return true;
# ifdef OF_HAVE_BLOCKS
}
# endif
}
- (void)dealloc
{
# ifdef OF_HAVE_BLOCKS
objc_release(_handler);
# endif
objc_release(_data);
[super dealloc];
}
@end
@implementation OFRunLoopWriteStringQueueItem
- (bool)handleObject: (id)object
|
| ︙ | ︙ | |||
765 766 767 768 769 770 771 | exception); if (newString == nil) return false; oldString = _string; _string = [newString copy]; | | | | | | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
exception);
if (newString == nil)
return false;
oldString = _string;
_string = [newString copy];
objc_release(oldString);
_writtenLength = 0;
return true;
} else {
# endif
if (![_delegate respondsToSelector: @selector(stream:
didWriteString:encoding:bytesWritten:exception:)])
return false;
newString = [_delegate stream: object
didWriteString: _string
encoding: _encoding
bytesWritten: _writtenLength
exception: exception];
if (newString == nil)
return false;
oldString = _string;
_string = [newString copy];
objc_release(oldString);
_writtenLength = 0;
return true;
# ifdef OF_HAVE_BLOCKS
}
# endif
}
- (void)dealloc
{
objc_release(_string);
# ifdef OF_HAVE_BLOCKS
objc_release(_handler);
# endif
[super dealloc];
}
@end
# if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
|
| ︙ | ︙ | |||
884 885 886 887 888 889 890 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
| | | 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
objc_release(_handler);
[super dealloc];
}
# endif
@end
@implementation OFRunLoopDatagramReceiveQueueItem
|
| ︙ | ︙ | |||
929 930 931 932 933 934 935 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
| | | 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
objc_release(_handler);
[super dealloc];
}
# endif
@end
@implementation OFRunLoopDatagramSendQueueItem
|
| ︙ | ︙ | |||
959 960 961 962 963 964 965 | newData = _handler(object, _data, &_receiver, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; | | | | | | 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
newData = _handler(object, _data, &_receiver, exception);
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
objc_release(oldData);
return true;
} else {
# endif
if (![_delegate respondsToSelector:
@selector(socket:didSendData:receiver:exception:)])
return false;
newData = [_delegate socket: object
didSendData: _data
receiver: &_receiver
exception: exception];
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
objc_release(oldData);
return true;
# ifdef OF_HAVE_BLOCKS
}
# endif
}
- (void)dealloc
{
# ifdef OF_HAVE_BLOCKS
objc_release(_handler);
# endif
objc_release(_data);
[super dealloc];
}
@end
@implementation OFRunLoopPacketReceiveQueueItem
- (bool)handleObject: (id)object
|
| ︙ | ︙ | |||
1031 1032 1033 1034 1035 1036 1037 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
| | | 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
objc_release(_handler);
[super dealloc];
}
# endif
@end
@implementation OFRunLoopPacketSendQueueItem
|
| ︙ | ︙ | |||
1060 1061 1062 1063 1064 1065 1066 | newData = _handler(object, _data, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; | | | | | | 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
newData = _handler(object, _data, exception);
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
objc_release(oldData);
return true;
} else {
# endif
if (![_delegate respondsToSelector:
@selector(socket:didSendData:exception:)])
return false;
newData = [_delegate socket: object
didSendData: _data
exception: exception];
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
objc_release(oldData);
return true;
# ifdef OF_HAVE_BLOCKS
}
# endif
}
- (void)dealloc
{
# ifdef OF_HAVE_BLOCKS
objc_release(_handler);
# endif
objc_release(_data);
[super dealloc];
}
@end
# ifdef OF_HAVE_SCTP
@implementation OFRunLoopSCTPReceiveQueueItem
|
| ︙ | ︙ | |||
1136 1137 1138 1139 1140 1141 1142 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
| | | 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 |
}
# endif
}
# ifdef OF_HAVE_BLOCKS
- (void)dealloc
{
objc_release(_handler);
[super dealloc];
}
# endif
@end
@implementation OFRunLoopSCTPSendQueueItem
|
| ︙ | ︙ | |||
1166 1167 1168 1169 1170 1171 1172 | newData = _handler(object, _data, _info, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; | | | | | | | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 |
newData = _handler(object, _data, _info, exception);
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
objc_release(oldData);
return true;
} else {
# endif
if (![_delegate respondsToSelector: @selector(
socket:didSendData:info:exception:)])
return false;
newData = [_delegate socket: object
didSendData: _data
info: _info
exception: exception];
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
objc_release(oldData);
return true;
# ifdef OF_HAVE_BLOCKS
}
# endif
}
- (void)dealloc
{
# ifdef OF_HAVE_BLOCKS
objc_release(_handler);
# endif
objc_release(_data);
objc_release(_info);
[super dealloc];
}
@end
# endif
#endif
|
| ︙ | ︙ | |||
1226 1227 1228 1229 1230 1231 1232 |
#else
return [self mainRunLoop];
#endif
}
+ (void)of_setMainRunLoop: (OFRunLoop *)runLoop
{
| | | | 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 |
#else
return [self mainRunLoop];
#endif
}
+ (void)of_setMainRunLoop: (OFRunLoop *)runLoop
{
mainRunLoop = objc_retain(runLoop);
}
static OFRunLoopState *
stateForMode(OFRunLoop *self, OFRunLoopMode mode, bool create,
bool createObserver)
{
OFRunLoopState *state;
#ifdef OF_HAVE_THREADS
[self->_statesMutex lock];
@try {
#endif
state = [self->_states objectForKey: mode];
if (create && state == nil) {
state = [[OFRunLoopState alloc] initWithMode: mode];
@try {
[self->_states setObject: state forKey: mode];
} @finally {
objc_release(state);
}
}
#ifdef OF_HAVE_SOCKETS
if (createObserver && state->_kernelEventObserver == nil) {
state->_kernelEventObserver =
[[OFKernelEventObserver alloc]
|
| ︙ | ︙ | |||
1284 1285 1286 1287 1288 1289 1290 | [state->_readQueues setObject: queue forKey: object]; \ } \ \ if (queue.count == 0) \ [state->_kernelEventObserver \ addObjectForReading: object]; \ \ | | | | | 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 |
[state->_readQueues setObject: queue forKey: object]; \
} \
\
if (queue.count == 0) \
[state->_kernelEventObserver \
addObjectForReading: object]; \
\
queueItem = objc_autorelease([[type alloc] init]);
# define NEW_WRITE(type, object, mode) \
void *pool = objc_autoreleasePoolPush(); \
OFRunLoop *runLoop = [self currentRunLoop]; \
OFRunLoopState *state = stateForMode(runLoop, mode, true, true); \
OFList *queue = [state->_writeQueues objectForKey: object]; \
type *queueItem; \
\
if (queue == nil) { \
queue = [OFList list]; \
[state->_writeQueues setObject: queue forKey: object]; \
} \
\
if (queue.count == 0) \
[state->_kernelEventObserver \
addObjectForWriting: object]; \
\
queueItem = objc_autorelease([[type alloc] init]);
#define QUEUE_ITEM \
[queue appendObject: queueItem]; \
\
objc_autoreleasePoolPop(pool);
+ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
stream
buffer: (void *)buffer
length: (size_t)length
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFStreamReadHandler)handler
# endif
delegate: (id <OFStreamDelegate>)delegate
{
NEW_READ(OFRunLoopReadQueueItem, stream, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_buffer = buffer;
queueItem->_length = length;
QUEUE_ITEM
|
| ︙ | ︙ | |||
1341 1342 1343 1344 1345 1346 1347 |
# ifdef OF_HAVE_BLOCKS
handler: (OFStreamReadHandler)handler
# endif
delegate: (id <OFStreamDelegate>)delegate
{
NEW_READ(OFRunLoopExactReadQueueItem, stream, mode)
| | | | | | | | | | | 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 |
# ifdef OF_HAVE_BLOCKS
handler: (OFStreamReadHandler)handler
# endif
delegate: (id <OFStreamDelegate>)delegate
{
NEW_READ(OFRunLoopExactReadQueueItem, stream, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_buffer = buffer;
queueItem->_exactLength = exactLength;
QUEUE_ITEM
}
+ (void)of_addAsyncReadStringForStream: (OFStream <OFReadyForReadingObserving
> *)stream
encoding: (OFStringEncoding)encoding
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFStreamStringReadHandler)handler
# endif
delegate: (id <OFStreamDelegate>)delegate
{
NEW_READ(OFRunLoopReadStringQueueItem, stream, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_encoding = encoding;
QUEUE_ITEM
}
+ (void)of_addAsyncReadLineForStream: (OFStream <OFReadyForReadingObserving> *)
stream
encoding: (OFStringEncoding)encoding
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFStreamStringReadHandler)handler
# endif
delegate: (id <OFStreamDelegate>)delegate
{
NEW_READ(OFRunLoopReadLineQueueItem, stream, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_encoding = encoding;
QUEUE_ITEM
}
+ (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *)
stream
data: (OFData *)data
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFStreamDataWrittenHandler)handler
# endif
delegate: (id <OFStreamDelegate>)delegate
{
NEW_WRITE(OFRunLoopWriteDataQueueItem, stream, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_data = [data copy];
QUEUE_ITEM
}
+ (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *)
stream
string: (OFString *)string
encoding: (OFStringEncoding)encoding
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFStreamStringWrittenHandler)handler
# endif
delegate: (id <OFStreamDelegate>)delegate
{
NEW_WRITE(OFRunLoopWriteStringQueueItem, stream, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_string = [string copy];
queueItem->_encoding = encoding;
QUEUE_ITEM
}
# if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
+ (void)of_addAsyncConnectForSocket: (id)sock
mode: (OFRunLoopMode)mode
delegate: (id <OFRunLoopConnectDelegate>)delegate
{
NEW_WRITE(OFRunLoopConnectQueueItem, sock, mode)
queueItem->_delegate = objc_retain(delegate);
QUEUE_ITEM
}
# endif
+ (void)of_addAsyncAcceptForSocket: (id)sock
mode: (OFRunLoopMode)mode
handler: (id)handler
delegate: (id)delegate
{
NEW_READ(OFRunLoopAcceptQueueItem, sock, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
QUEUE_ITEM
}
+ (void)of_addAsyncReceiveForDatagramSocket: (OFDatagramSocket *)sock
buffer: (void *)buffer
length: (size_t)length
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFDatagramSocketPacketReceivedHandler)handler
# endif
delegate: (id <OFDatagramSocketDelegate>)delegate
{
NEW_READ(OFRunLoopDatagramReceiveQueueItem, sock, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_buffer = buffer;
queueItem->_length = length;
QUEUE_ITEM
}
+ (void)of_addAsyncSendForDatagramSocket: (OFDatagramSocket *)sock
data: (OFData *)data
receiver: (const OFSocketAddress *)receiver
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFDatagramSocketDataSentHandler)handler
# endif
delegate: (id <OFDatagramSocketDelegate>)delegate
{
NEW_WRITE(OFRunLoopDatagramSendQueueItem, sock, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_data = [data copy];
queueItem->_receiver = *receiver;
QUEUE_ITEM
|
| ︙ | ︙ | |||
1515 1516 1517 1518 1519 1520 1521 |
# ifdef OF_HAVE_BLOCKS
handler: (OFSequencedPacketSocketPacketReceivedHandler)handler
# endif
delegate: (id <OFSequencedPacketSocketDelegate>)delegate
{
NEW_READ(OFRunLoopPacketReceiveQueueItem, sock, mode)
| | | | 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 |
# ifdef OF_HAVE_BLOCKS
handler: (OFSequencedPacketSocketPacketReceivedHandler)handler
# endif
delegate: (id <OFSequencedPacketSocketDelegate>)delegate
{
NEW_READ(OFRunLoopPacketReceiveQueueItem, sock, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_buffer = buffer;
queueItem->_length = length;
QUEUE_ITEM
}
+ (void)of_addAsyncSendForSequencedPacketSocket: (OFSequencedPacketSocket *)sock
data: (OFData *)data
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFSequencedPacketSocketDataSentHandler)handler
# endif
delegate: (id <OFSequencedPacketSocketDelegate>)delegate
{
NEW_WRITE(OFRunLoopPacketSendQueueItem, sock, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_data = [data copy];
QUEUE_ITEM
}
|
| ︙ | ︙ | |||
1557 1558 1559 1560 1561 1562 1563 |
# ifdef OF_HAVE_BLOCKS
handler: (OFSCTPSocketMessageReceivedHandler)handler
# endif
delegate: (id <OFSCTPSocketDelegate>)delegate
{
NEW_READ(OFRunLoopSCTPReceiveQueueItem, sock, mode)
| | | | 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 |
# ifdef OF_HAVE_BLOCKS
handler: (OFSCTPSocketMessageReceivedHandler)handler
# endif
delegate: (id <OFSCTPSocketDelegate>)delegate
{
NEW_READ(OFRunLoopSCTPReceiveQueueItem, sock, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_buffer = buffer;
queueItem->_length = length;
QUEUE_ITEM
}
+ (void)of_addAsyncSendForSCTPSocket: (OFSCTPSocket *)sock
data: (OFData *)data
info: (OFSCTPMessageInfo)info
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
handler: (OFSCTPSocketDataSentHandler)handler
# endif
delegate: (id <OFSCTPSocketDelegate>)delegate
{
NEW_WRITE(OFRunLoopSCTPSendQueueItem, sock, mode)
queueItem->_delegate = objc_retain(delegate);
# ifdef OF_HAVE_BLOCKS
queueItem->_handler = [handler copy];
# endif
queueItem->_data = [data copy];
queueItem->_info = [info copy];
QUEUE_ITEM
|
| ︙ | ︙ | |||
1646 1647 1648 1649 1650 1651 1652 |
_states = [[OFMutableDictionary alloc] init];
state = [[OFRunLoopState alloc]
initWithMode: OFDefaultRunLoopMode];
@try {
[_states setObject: state forKey: OFDefaultRunLoopMode];
} @finally {
| | | | | | 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 |
_states = [[OFMutableDictionary alloc] init];
state = [[OFRunLoopState alloc]
initWithMode: OFDefaultRunLoopMode];
@try {
[_states setObject: state forKey: OFDefaultRunLoopMode];
} @finally {
objc_release(state);
}
#ifdef OF_HAVE_THREADS
_statesMutex = [[OFMutex alloc] init];
#endif
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (void)dealloc
{
objc_release(_states);
#ifdef OF_HAVE_THREADS
objc_release(_statesMutex);
#endif
[super dealloc];
}
- (void)addTimer: (OFTimer *)timer
{
|
| ︙ | ︙ | |||
1882 1883 1884 1885 1886 1887 1888 |
#endif
OFListItem listItem =
state->_timersQueue.firstListItem;
if (listItem != NULL &&
[OFListItemObject(listItem) fireDate]
.timeIntervalSinceNow <= 0) {
| > | < | 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 |
#endif
OFListItem listItem =
state->_timersQueue.firstListItem;
if (listItem != NULL &&
[OFListItemObject(listItem) fireDate]
.timeIntervalSinceNow <= 0) {
timer = objc_autorelease(objc_retain(
OFListItemObject(listItem)));
[state->_timersQueue
removeListItem: listItem];
[timer of_setInRunLoop: nil mode: nil];
} else
break;
|
| ︙ | ︙ |
Changes to src/OFSCTPSocket.m.
| ︙ | ︙ | |||
75 76 77 78 79 80 81 |
id _exception;
}
@end
@implementation OFSCTPSocketConnectDelegate
- (void)dealloc
{
| | | | 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 |
id _exception;
}
@end
@implementation OFSCTPSocketConnectDelegate
- (void)dealloc
{
objc_release(_exception);
[super dealloc];
}
- (void)socket: (OFSCTPSocket *)sock
didConnectToHost: (OFString *)host
port: (uint16_t)port
exception: (id)exception
{
_done = true;
_exception = objc_retain(exception);
}
@end
@implementation OFSCTPSocket
@dynamic delegate;
- (bool)of_createSocketForAddress: (const OFSocketAddress *)address
|
| ︙ | ︙ | |||
158 159 160 161 162 163 164 |
}
- (void)connectToHost: (OFString *)host port: (uint16_t)port
{
void *pool = objc_autoreleasePoolPush();
id <OFSCTPSocketDelegate> delegate = _delegate;
OFSCTPSocketConnectDelegate *connectDelegate =
| | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
}
- (void)connectToHost: (OFString *)host port: (uint16_t)port
{
void *pool = objc_autoreleasePoolPush();
id <OFSCTPSocketDelegate> delegate = _delegate;
OFSCTPSocketConnectDelegate *connectDelegate =
objc_autorelease([[OFSCTPSocketConnectDelegate alloc] init]);
OFRunLoop *runLoop = [OFRunLoop currentRunLoop];
_delegate = connectDelegate;
[self asyncConnectToHost: host
port: port
runLoopMode: connectRunLoopMode];
|
| ︙ | ︙ | |||
196 197 198 199 200 201 202 |
runLoopMode: (OFRunLoopMode)runLoopMode
{
void *pool = objc_autoreleasePoolPush();
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyOpenException exceptionWithObject: self];
| | | | | | < | | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
runLoopMode: (OFRunLoopMode)runLoopMode
{
void *pool = objc_autoreleasePoolPush();
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyOpenException exceptionWithObject: self];
[objc_autorelease([[OFAsyncIPSocketConnector alloc]
initWithSocket: self
host: host
port: port
delegate: _delegate
handler: NULL]) startWithRunLoopMode: runLoopMode];
objc_autoreleasePoolPop(pool);
}
#ifdef OF_HAVE_BLOCKS
- (void)asyncConnectToHost: (OFString *)host
port: (uint16_t)port
|
| ︙ | ︙ | |||
228 229 230 231 232 233 234 |
handler: (OFSCTPSocketConnectedHandler)handler
{
void *pool = objc_autoreleasePoolPush();
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyOpenException exceptionWithObject: self];
| | | | | | < | | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
handler: (OFSCTPSocketConnectedHandler)handler
{
void *pool = objc_autoreleasePoolPush();
if (_socket != OFInvalidSocketHandle)
@throw [OFAlreadyOpenException exceptionWithObject: self];
[objc_autorelease([[OFAsyncIPSocketConnector alloc]
initWithSocket: self
host: host
port: port
delegate: nil
handler: handler]) startWithRunLoopMode: runLoopMode];
objc_autoreleasePoolPop(pool);
}
#endif
- (OFSocketAddress)bindToHost: (OFString *)host port: (uint16_t)port
{
|
| ︙ | ︙ |
Changes to src/OFSHA1Hash.m.
| ︙ | ︙ | |||
112 113 114 115 116 117 118 |
+ (size_t)blockSize
{
return blockSize;
}
+ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
| | | | | | 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
+ (size_t)blockSize
{
return blockSize;
}
+ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
return objc_autoreleaseReturnValue([[self alloc]
initWithAllowsSwappableMemory: allowsSwappableMemory]);
}
- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
self = [super init];
@try {
_iVarsData = [[OFSecureData alloc]
initWithCount: sizeof(*_iVars)
allowsSwappableMemory: allowsSwappableMemory];
_iVars = _iVarsData.mutableItems;
_allowsSwappableMemory = allowsSwappableMemory;
[self of_resetState];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)of_init
{
return [super init];
}
- (void)dealloc
{
objc_release(_iVarsData);
[super dealloc];
}
- (size_t)digestSize
{
return digestSize;
|
| ︙ | ︙ |
Changes to src/OFSHA224Or256Hash.m.
| ︙ | ︙ | |||
132 133 134 135 136 137 138 |
+ (size_t)blockSize
{
return blockSize;
}
+ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
| | | | | | 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 |
+ (size_t)blockSize
{
return blockSize;
}
+ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
return objc_autoreleaseReturnValue([[self alloc]
initWithAllowsSwappableMemory: allowsSwappableMemory]);
}
- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
self = [super init];
@try {
_iVarsData = [[OFSecureData alloc]
initWithCount: sizeof(*_iVars)
allowsSwappableMemory: allowsSwappableMemory];
_iVars = _iVarsData.mutableItems;
_allowsSwappableMemory = allowsSwappableMemory;
if (self.class == [OFSHA224Or256Hash class]) {
[self doesNotRecognizeSelector: _cmd];
abort();
}
[self of_resetState];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)of_init
{
return [super init];
}
- (void)dealloc
{
objc_release(_iVarsData);
[super dealloc];
}
- (size_t)digestSize
{
OF_UNRECOGNIZED_SELECTOR
|
| ︙ | ︙ |
Changes to src/OFSHA384Or512Hash.m.
| ︙ | ︙ | |||
143 144 145 146 147 148 149 |
+ (size_t)blockSize
{
return blockSize;
}
+ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
| | | | | | 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 192 193 194 195 196 197 198 |
+ (size_t)blockSize
{
return blockSize;
}
+ (instancetype)hashWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
return objc_autoreleaseReturnValue([[self alloc]
initWithAllowsSwappableMemory: allowsSwappableMemory]);
}
- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory
{
self = [super init];
@try {
_iVarsData = [[OFSecureData alloc]
initWithCount: sizeof(*_iVars)
allowsSwappableMemory: allowsSwappableMemory];
_iVars = _iVarsData.mutableItems;
_allowsSwappableMemory = allowsSwappableMemory;
if (self.class == [OFSHA384Or512Hash class]) {
[self doesNotRecognizeSelector: _cmd];
abort();
}
[self of_resetState];
} @catch (id e) {
objc_release(self);
@throw e;
}
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)of_init
{
return [super init];
}
- (void)dealloc
{
objc_release(_iVarsData);
[super dealloc];
}
- (size_t)digestSize
{
OF_UNRECOGNIZED_SELECTOR
|
| ︙ | ︙ |