Use ARC functions for RR

FossilOrigin-Name: a19b24ae129c1144fed2ba35d5a57ff2298b58ebb3c8f5071613e9efe67e4f63
This commit is contained in:
Jonathan Schleifer 2025-04-19 13:34:33 +00:00
parent bf51ce812c
commit 68fff75083
5 changed files with 42 additions and 28 deletions

View file

@ -34,7 +34,7 @@
@try { @try {
_parameters = [[OFDictionary alloc] init]; _parameters = [[OFDictionary alloc] init];
} @catch (id e) { } @catch (id e) {
[self release]; objc_release(self);
@throw e; @throw e;
} }
@ -43,7 +43,7 @@
- (void)dealloc - (void)dealloc
{ {
[_parameters release]; objc_release(_parameters);
[self close]; [self close];

View file

@ -26,7 +26,8 @@
+ (instancetype)pg_resultWithResult: (PGresult *)result + (instancetype)pg_resultWithResult: (PGresult *)result
{ {
return [[[self alloc] pg_initWithResult: result] autorelease]; return objc_autoreleaseReturnValue(
[[self alloc] pg_initWithResult: result]);
} }
- (instancetype)pg_initWithResult: (PGresult *)result - (instancetype)pg_initWithResult: (PGresult *)result

View file

@ -65,23 +65,29 @@ convertType(PGresult *res, int column, OFString *string)
@implementation PGSQLResultRow @implementation PGSQLResultRow
+ (instancetype)pg_rowWithResult: (PGSQLResult *)result row: (int)row + (instancetype)pg_rowWithResult: (PGSQLResult *)result row: (int)row
{ {
return [[[self alloc] pg_initWithResult: result row: row] autorelease]; return objc_autoreleaseReturnValue(
[[self alloc] pg_initWithResult: result row: row]);
} }
- (instancetype)pg_initWithResult: (PGSQLResult *)result row: (int)row - (instancetype)pg_initWithResult: (PGSQLResult *)result row: (int)row
{ {
self = [super init]; self = [super init];
_result = [result retain]; @try {
_res = result.pg_result; _result = objc_retain(result);
_row = row; _res = result.pg_result;
_row = row;
} @catch (id e) {
objc_release(self);
@throw e;
}
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[_result release]; objc_release(_result);
[super dealloc]; [super dealloc];
} }
@ -115,16 +121,16 @@ convertType(PGresult *res, int column, OFString *string)
- (OFEnumerator *)keyEnumerator - (OFEnumerator *)keyEnumerator
{ {
return [[[PGSQLResultRowKeyEnumerator alloc] return objc_autoreleaseReturnValue(
initWithResult: _result [[PGSQLResultRowKeyEnumerator alloc] initWithResult: _result
row: _row] autorelease]; row: _row]);
} }
- (OFEnumerator *)objectEnumerator - (OFEnumerator *)objectEnumerator
{ {
return [[[PGSQLResultRowObjectEnumerator alloc] return objc_autoreleaseReturnValue(
initWithResult: _result [[PGSQLResultRowObjectEnumerator alloc] initWithResult: _result
row: _row] autorelease]; row: _row]);
} }
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
@ -165,17 +171,22 @@ convertType(PGresult *res, int column, OFString *string)
{ {
self = [super init]; self = [super init];
_result = [result retain]; @try {
_res = result.pg_result; _result = objc_retain(result);
_row = row; _res = result.pg_result;
_count = PQnfields(_res); _row = row;
_count = PQnfields(_res);
} @catch (id e) {
objc_release(self);
@throw e;
}
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[_result release]; objc_release(_result);
[super dealloc]; [super dealloc];
} }

View file

@ -29,7 +29,8 @@
+ (instancetype)exceptionWithConnection: (PGSQLConnection *)connection + (instancetype)exceptionWithConnection: (PGSQLConnection *)connection
{ {
return [[[self alloc] initWithConnection: connection] autorelease]; return objc_autoreleaseReturnValue(
[[self alloc] initWithConnection: connection]);
} }
- (instancetype)init - (instancetype)init
@ -42,12 +43,12 @@
self = [super init]; self = [super init];
@try { @try {
_connection = [connection retain]; _connection = objc_retain(connection);
_errorMessage = [[OFString alloc] _errorMessage = [[OFString alloc]
initWithCString: PQerrorMessage([_connection pg_connection]) initWithCString: PQerrorMessage([_connection pg_connection])
encoding: [OFLocale encoding]]; encoding: [OFLocale encoding]];
} @catch (id e) { } @catch (id e) {
[self release]; objc_release(self);
@throw e; @throw e;
} }
@ -56,8 +57,8 @@
- (void)dealloc - (void)dealloc
{ {
[_connection release]; objc_release(_connection);
[_errorMessage release]; objc_release(_errorMessage);
[super dealloc]; [super dealloc];
} }

View file

@ -29,8 +29,9 @@
+ (instancetype)exceptionWithConnection: (PGSQLConnection *)connection + (instancetype)exceptionWithConnection: (PGSQLConnection *)connection
command: (OFConstantString *)command command: (OFConstantString *)command
{ {
return [[[self alloc] initWithConnection: connection return objc_autoreleaseReturnValue(
command: command] autorelease]; [[self alloc] initWithConnection: connection
command: command]);
} }
- (instancetype)initWithConnection: (PGSQLConnection *)connection - (instancetype)initWithConnection: (PGSQLConnection *)connection
@ -46,7 +47,7 @@
@try { @try {
_command = [command copy]; _command = [command copy];
} @catch (id e) { } @catch (id e) {
[self release]; objc_release(self);
@throw e; @throw e;
} }
@ -55,7 +56,7 @@
- (void)dealloc - (void)dealloc
{ {
[_command release]; objc_release(_command);
[super dealloc]; [super dealloc];
} }