Skip to content
Permalink
Browse files

Replace all non-cyclic NSAutoreleasepools with @autoreleasepool

  • Loading branch information
dmoagx committed May 3, 2018
1 parent 7f35608 commit b49edf67744ba6e54b7c0bdab7dc197cf8faac96
Showing with 2,755 additions and 2,859 deletions.
  1. +50 −52 Frameworks/PostgresKit/Source/PGPostgresConnection.m
  2. +22 −24 Frameworks/PostgresKit/Source/PGPostgresConnectionParameters.m
  3. +135 −143 Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
  4. +63 −63 Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m
  5. +1 −1 Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m
  6. +121 −122 Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m
  7. +60 −59 Source/GeneratePreviewForURL.m
  8. +38 −41 Source/GenerateThumbnailForURL.m
  9. +2 −2 Source/SPCSVExporter.m
  10. +122 −127 Source/SPConnectionController.m
  11. +290 −292 Source/SPCustomQuery.m
  12. +8 −11 Source/SPDataImport.m
  13. +390 −412 Source/SPDatabaseDocument.m
  14. +233 −234 Source/SPDatabaseStructure.m
  15. +47 −49 Source/SPExportController.m
  16. +7 −11 Source/SPExporter.m
  17. +67 −69 Source/SPFavoritesController.m
  18. +33 −35 Source/SPFavoritesExporter.m
  19. +23 −26 Source/SPFavoritesImporter.m
  20. +46 −48 Source/SPFileHandle.m
  21. +0 −1 Source/SPHistoryController.h
  22. +84 −85 Source/SPHistoryController.m
  23. +119 −121 Source/SPIndexesController.m
  24. +6 −6 Source/SPNavigatorController.m
  25. +41 −44 Source/SPProcessListController.m
  26. +216 −218 Source/SPSSHTunnel.m
  27. +161 −170 Source/SPTableContent.m
  28. +44 −47 Source/SPTableStructure.m
  29. +87 −83 Source/SPTablesList.m
  30. +52 −54 Source/SPUserManager.m
  31. +140 −162 Source/SequelProTunnelAssistant.m
  32. +47 −47 Source/xibLocalizationPostprocessor.m
@@ -297,64 +297,62 @@ - (BOOL)cancelCurrentQuery:(NSError **)error
*/
- (void)_pollConnection:(NSNumber *)isReset
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

BOOL reset = isReset && [isReset boolValue];

int sock = PQsocket(_connection);

if (sock == -1) {
[pool release];
return;
}

struct pollfd fdinfo[1];

fdinfo[0].fd = sock;
fdinfo[0].events = POLLIN|POLLOUT;

PostgresPollingStatusType status;

do
{
status = reset ? PQresetPoll(_connection) : PQconnectPoll(_connection);

if (status == PGRES_POLLING_READING || status == PGRES_POLLING_WRITING) {
if (poll(fdinfo, 1, -1) < 0) break;
}
}
while (status != PGRES_POLLING_OK && status != PGRES_POLLING_FAILED);

if (status == PGRES_POLLING_OK && [self isConnected]) {

// Increase error verbosity
PQsetErrorVerbosity(_connection, PQERRORS_VERBOSE);

// Set notice processor
PQsetNoticeProcessor(_connection, _PGPostgresConnectionNoticeProcessor, self);

// Register or clear type extensions
NSInteger success = reset ? PQclearTypes(_connection) : PQinitTypes(_connection);

if (!success) {
NSLog(@"PostgresKit: Error: Failed to initialise or clear type extensions. Connection might return unexpected results!");
@autoreleasepool {
BOOL reset = isReset && [isReset boolValue];

int sock = PQsocket(_connection);

if (sock == -1) {
[pool release];
return;
}

[self _loadDatabaseParameters];

if (reset) {
if (_delegate && [_delegate respondsToSelector:@selector(connectionReset:)]) {
[_delegate performSelectorOnMainThread:@selector(connectionReset:) withObject:self waitUntilDone:NO];

struct pollfd fdinfo[1];

fdinfo[0].fd = sock;
fdinfo[0].events = POLLIN|POLLOUT;

PostgresPollingStatusType status;

do
{
status = reset ? PQresetPoll(_connection) : PQconnectPoll(_connection);

if (status == PGRES_POLLING_READING || status == PGRES_POLLING_WRITING) {
if (poll(fdinfo, 1, -1) < 0) break;
}
}
else {
if (_delegate && [_delegate respondsToSelector:@selector(connectionEstablished:)]) {
[_delegate performSelectorOnMainThread:@selector(connectionEstablished:) withObject:self waitUntilDone:NO];
while (status != PGRES_POLLING_OK && status != PGRES_POLLING_FAILED);

if (status == PGRES_POLLING_OK && [self isConnected]) {

// Increase error verbosity
PQsetErrorVerbosity(_connection, PQERRORS_VERBOSE);

// Set notice processor
PQsetNoticeProcessor(_connection, _PGPostgresConnectionNoticeProcessor, self);

// Register or clear type extensions
NSInteger success = reset ? PQclearTypes(_connection) : PQinitTypes(_connection);

if (!success) {
NSLog(@"PostgresKit: Error: Failed to initialise or clear type extensions. Connection might return unexpected results!");
}

[self _loadDatabaseParameters];

if (reset) {
if (_delegate && [_delegate respondsToSelector:@selector(connectionReset:)]) {
[_delegate performSelectorOnMainThread:@selector(connectionReset:) withObject:self waitUntilDone:NO];
}
}
else {
if (_delegate && [_delegate respondsToSelector:@selector(connectionEstablished:)]) {
[_delegate performSelectorOnMainThread:@selector(connectionEstablished:) withObject:self waitUntilDone:NO];
}
}
}
}

[pool release];
}

/**
@@ -138,32 +138,30 @@ - (id)valueForParameter:(NSString *)parameter
*/
- (void)_loadParameters:(id)object
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

pthread_mutex_lock(&_readLock);

NSArray *parameters = (NSArray *)object;

if (!_parameters) {
_parameters = [[NSMutableDictionary alloc] initWithCapacity:[parameters count]];
}

for (NSString *parameter in parameters)
{
const char *value = PQparameterStatus([_connection postgresConnection], [parameter UTF8String]);

if (!value) continue;

NSString *stringValue = [NSString stringWithUTF8String:value];
@autoreleasepool {
pthread_mutex_lock(&_readLock);

id paramObject = [self _isBooleanParameterValue:stringValue] ? (id)[NSNumber numberWithBool:[self _booleanForParameterValue:stringValue]] : stringValue;

[_parameters setObject:paramObject forKey:parameter];
NSArray *parameters = (NSArray *)object;

if (!_parameters) {
_parameters = [[NSMutableDictionary alloc] initWithCapacity:[parameters count]];
}

for (NSString *parameter in parameters)
{
const char *value = PQparameterStatus([_connection postgresConnection], [parameter UTF8String]);

if (!value) continue;

NSString *stringValue = [NSString stringWithUTF8String:value];

id paramObject = [self _isBooleanParameterValue:stringValue] ? (id)[NSNumber numberWithBool:[self _booleanForParameterValue:stringValue]] : stringValue;

[_parameters setObject:paramObject forKey:parameter];
}

pthread_mutex_unlock(&_readLock);
}

pthread_mutex_unlock(&_readLock);

[pool release];
}

/**

0 comments on commit b49edf6

Please sign in to comment.