@@ -15,13 +15,15 @@ [super dealloc]; } - (void)connect { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFEnumerator *keyEnumerator = [_parameters keyEnumerator]; - OFEnumerator *objectEnumerator = [_parameters objectEnumerator]; + void *pool = objc_autoreleasePoolPush(); + OFEnumerator OF_GENERIC(OFString *) *keyEnumerator = + [_parameters keyEnumerator]; + OFEnumerator OF_GENERIC(OFString *) *objectEnumerator = + [_parameters objectEnumerator]; OFMutableString *connectionInfo = nil; OFString *key, *object; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { @@ -37,11 +39,11 @@ if (PQstatus(_connnection) == CONNECTION_BAD) @throw [PGConnectionFailedException exceptionWithConnection: self]; - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)reset { PQreset(_connnection); @@ -53,11 +55,11 @@ PQfinish(_connnection); _connnection = NULL; } -- (PGResult*)executeCommand: (OFConstantString*)command +- (PGResult *)executeCommand: (OFConstantString *)command { PGresult *result = PQexec(_connnection, [command UTF8String]); if (PQresultStatus(result) == PGRES_FATAL_ERROR) { PQclear(result); @@ -78,14 +80,14 @@ exceptionWithConnection: self command: command]; } } -- (PGResult*)executeCommand: (OFConstantString*)command - parameters: (id)parameter, ... +- (PGResult *)executeCommand: (OFConstantString *)command + parameters: (id)parameter, ... { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); PGresult *result; const char **values; va_list args, args2; int argsCount; @@ -128,11 +130,11 @@ argsCount, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } - [pool release]; + objc_autoreleasePoolPop(pool); switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: return [PGResult PG_resultWithResult: result]; case PGRES_COMMAND_OK: @@ -144,14 +146,14 @@ exceptionWithConnection: self command: command]; } } -- (void)insertRow: (OFDictionary*)row - intoTable: (OFString*)table +- (void)insertRow: (OFDictionary *)row + intoTable: (OFString *)table { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); OFMutableString *command; OFEnumerator *enumerator; const char **values; PGresult *result; OFString *key, *value; @@ -196,11 +198,11 @@ (int)count, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } - [pool release]; + objc_autoreleasePoolPop(pool); if (PQresultStatus(result) != PGRES_COMMAND_OK) { PQclear(result); @throw [PGCommandFailedException exceptionWithConnection: self @@ -208,24 +210,18 @@ } PQclear(result); } -- (void)insertRows: (OFArray*)rows - intoTable: (OFString*)table -{ - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFEnumerator *enumerator = [rows objectEnumerator]; - OFDictionary *row; - - while ((row = [enumerator nextObject]) != nil) +- (void)insertRows: (OFArray OF_GENERIC(OFDictionary *) *)rows + intoTable: (OFString *)table +{ + for (OFDictionary *row in rows) [self insertRow: row intoTable: table]; - - [pool release]; } -- (PGconn*)PG_connection +- (PGconn *)PG_connection { return _connnection; } @end