aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbamse16 <marius@marius.me.uk>2009-06-05 15:07:25 +0000
committerbamse16 <marius@marius.me.uk>2009-06-05 15:07:25 +0000
commit67a3148cec8bc7d1c6f52f60c8ce93a4fe0b8ece (patch)
tree14dbf0a8861ade6a232dfe2d0fdfab0807375aa5
parentb3d173a9bf9ade79a06202b5666b105936ef0dff (diff)
downloadsequelpro-67a3148cec8bc7d1c6f52f60c8ce93a4fe0b8ece.tar.gz
sequelpro-67a3148cec8bc7d1c6f52f60c8ce93a4fe0b8ece.tar.bz2
sequelpro-67a3148cec8bc7d1c6f52f60c8ce93a4fe0b8ece.zip
Fixed some memory leaks found using llvm/clang. There are still some to fix
-rw-r--r--Source/CMMCPConnection.m8
-rw-r--r--Source/CMTextView.m16
-rw-r--r--Source/CustomQuery.m4
-rw-r--r--Source/KeyChain.m8
-rw-r--r--Source/NoodleLineNumberView.m1
-rw-r--r--Source/SPTableData.m5
-rw-r--r--Source/TableContent.m3
-rw-r--r--Source/TableDump.m17
-rw-r--r--Source/TablesList.m15
-rw-r--r--Source/TunnelPassphraseRequester.m10
10 files changed, 55 insertions, 32 deletions
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index 4ee9263e..478d5684 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -929,7 +929,6 @@ static void forcePingTimeout(int signalNumber)
lastKeepAliveSuccess = [[NSDate alloc] initWithTimeIntervalSinceNow:0];
}
-
/*
* Modified version of the original to support a supplied encoding.
* For internal use only. Transforms a NSString to a C type string (ending with \0).
@@ -948,4 +947,9 @@ static void forcePingTimeout(int signalNumber)
return (const char *)[theData bytes];
}
-@end
+- (void) dealloc
+{
+ [super dealloc];
+}
+
+@end \ No newline at end of file
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index b8392e30..27df70ed 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -128,8 +128,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
NSMutableArray *compl = [[NSMutableArray alloc] initWithCapacity:32];
NSMutableArray *possibleCompletions = [[NSMutableArray alloc] initWithCapacity:32];
- unsigned i, insindex;
- insindex = 0;
+ unsigned i;
if([mySQLConnection isConnected] && !isDictMode)
{
@@ -294,7 +293,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[completionPopUp setCaretPos:pos];
[completionPopUp orderFront:self];
-
+ [completionPopUp release];
}
@@ -2332,6 +2331,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[showMySQLHelpForMenuItem setTag:SP_CQ_SEARCH_IN_MYSQL_HELP_MENU_ITEM_TAG];
[showMySQLHelpForMenuItem setKeyEquivalentModifierMask:NSControlKeyMask];
[menu insertItem:showMySQLHelpForMenuItem atIndex:4];
+ [showMySQLHelpForMenuItem release];
} else {
[[menu itemWithTag:SP_CQ_SEARCH_IN_MYSQL_HELP_MENU_ITEM_TAG] setTitle:showMySQLHelpFor];
}
@@ -2341,6 +2341,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[copyAsRTFMenuItem setTag:SP_CQ_COPY_AS_RTF_MENU_ITEM_TAG];
[copyAsRTFMenuItem setKeyEquivalentModifierMask:NSControlKeyMask];
[menu insertItem:copyAsRTFMenuItem atIndex:2];
+ [copyAsRTFMenuItem release];
}
if ([[[self class] defaultMenu] itemWithTag:SP_CQ_SELECT_CURRENT_QUERY_MENU_ITEM_TAG] == nil)
{
@@ -2348,6 +2349,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[selectCurrentQueryMenuItem setTag:SP_CQ_SELECT_CURRENT_QUERY_MENU_ITEM_TAG];
[selectCurrentQueryMenuItem setKeyEquivalentModifierMask:NSControlKeyMask];
[menu insertItem:selectCurrentQueryMenuItem atIndex:4];
+ [selectCurrentQueryMenuItem release];
}
// Hide "Select Active Query" if self is not editable
[[menu itemAtIndex:4] setHidden:![self isEditable]];
@@ -2520,6 +2522,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
modalDelegate:self
didEndSelector:@selector(dragAlertSheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
+ [alert release];
} else
[self insertFileContentOfFile:filepath];
@@ -2654,6 +2657,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[self insertText:@""];
}
+- (void) dealloc
+{
+ [super dealloc];
+}
-@end
-
+@end \ No newline at end of file
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 63a1efd4..b678abfe 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -1409,6 +1409,7 @@
{
WebHistoryItem *aWebHistoryItem = [[WebHistoryItem alloc] initWithURLString:[NSString stringWithFormat:@"applewebdata://%@", searchString] title:searchString lastVisitedTimeInterval:[[NSDate date] timeIntervalSinceDate:[NSDate distantFuture]]];
[[helpWebView backForwardList] addItem:aWebHistoryItem];
+ [aWebHistoryItem release];
}
// validate goback/forward buttons
@@ -1805,12 +1806,13 @@
[searchInMySQLonline setEnabled:YES];
[searchInMySQLonline setTarget:self];
[webViewMenuItems insertObject:searchInMySQLonline atIndex:0];
+ [searchInMySQLonline release];
searchInMySQL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Search in MySQL Help", @"Search in MySQL Help") action:@selector(showHelpForWebViewSelection:) keyEquivalent:@""];
[searchInMySQL setEnabled:YES];
[searchInMySQL setTarget:self];
[webViewMenuItems insertObject:searchInMySQL atIndex:0];
-
+ [searchInMySQL release];
}
return webViewMenuItems;
diff --git a/Source/KeyChain.m b/Source/KeyChain.m
index da3e761c..ec5ee03f 100644
--- a/Source/KeyChain.m
+++ b/Source/KeyChain.m
@@ -116,10 +116,10 @@
password = [NSString stringWithCString:passwordData length:passwordLength];
// Free the data allocated by SecKeychainFindGenericPassword:
- status = SecKeychainItemFreeContent(
- NULL, // No attribute data to release
- passwordData // Release data
- );
+ SecKeychainItemFreeContent(
+ NULL, // No attribute data to release
+ passwordData // Release data
+ );
}
return password;
diff --git a/Source/NoodleLineNumberView.m b/Source/NoodleLineNumberView.m
index 018e3e0d..2cd2508a 100644
--- a/Source/NoodleLineNumberView.m
+++ b/Source/NoodleLineNumberView.m
@@ -402,7 +402,6 @@
range.length++;
count = [lines count];
- index = 0;
for (line = [self lineNumberForCharacterIndex:range.location inText:text]; line < count; line++)
{
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index ebb03a71..d01dd4cd 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -445,11 +445,9 @@
if( [[parts objectAtIndex:nextOffs+1] hasPrefix:@"SET"] ) {
[constraintDetails setObject:@"SET NULL"
forKey:@"update"];
- nextOffs = 13;
} else if( [[parts objectAtIndex:nextOffs+1] hasPrefix:@"NO"] ) {
[constraintDetails setObject:@"NO ACTION"
forKey:@"update"];
- nextOffs = 13;
} else {
[constraintDetails setObject:[parts objectAtIndex:nextOffs+1]
forKey:@"update"];
@@ -460,11 +458,9 @@
if( [[parts objectAtIndex:nextOffs+1] hasPrefix:@"SET"] ) {
[constraintDetails setObject:@"SET NULL"
forKey:@"delete"];
- nextOffs = 13;
} else if( [[parts objectAtIndex:nextOffs+1] hasPrefix:@"NO"] ) {
[constraintDetails setObject:@"NO ACTION"
forKey:@"delete"];
- nextOffs = 13;
} else {
[constraintDetails setObject:[parts objectAtIndex:nextOffs+1]
forKey:@"delete"];
@@ -472,6 +468,7 @@
}
}
[constraints addObject:constraintDetails];
+ [constraintDetails release];
}
// primary key
else if( [[parts objectAtIndex:0] hasPrefix:@"PRIMARY"] ) {
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 555b1a13..c93f4f00 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -738,7 +738,7 @@
{
NSMutableDictionary *tempRow;
CMMCPResult *queryResult;
- NSDictionary *row, *dbDataRow;
+ NSDictionary *row, *dbDataRow = nil;
int i;
// Check whether a save of the current row is required.
@@ -766,7 +766,6 @@
dbDataRow = [queryResult fetchRowAsDictionary];
}
-
//set autoincrement fields to NULL
queryResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [selectedTable backtickQuotedString]]];
if ([queryResult numOfRows]) [queryResult dataSeek:0];
diff --git a/Source/TableDump.m b/Source/TableDump.m
index 55c6fc21..5922ccd2 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -397,7 +397,7 @@
- (void)importBackgroundProcess:(NSString*)filename
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- SPSQLParser *dumpFile;
+ SPSQLParser *dumpFile = nil;
NSError *errorStr = nil;
NSMutableString *errors = [NSMutableString string];
NSString *fileType = [[importFormatPopup selectedItem] title];
@@ -523,8 +523,6 @@
} else if ( [fileType isEqualToString:@"CSV"] ) {
int code;
- NSPopUpButtonCell *buttonCell = [[NSPopUpButtonCell alloc] init];
-
//open progress sheet
[NSApp beginSheet:singleProgressSheet
modalForWindow:tableWindow
@@ -601,10 +599,12 @@
[recordCountLabel setStringValue:[NSString stringWithFormat:@"%i of %i records", currentRow+1, [importArray count]]];
//set up tableView buttons
+ NSPopUpButtonCell *buttonCell = [[NSPopUpButtonCell alloc] init];
[buttonCell setControlSize:NSSmallControlSize];
[buttonCell setFont:[NSFont labelFontOfSize:[NSFont smallSystemFontSize]]];
[buttonCell setBordered:NO];
[[fieldMappingTableView tableColumnWithIdentifier:@"value"] setDataCell:buttonCell];
+ [buttonCell release];
[self updateFieldMappingButtonCell];
[fieldMappingTableView reloadData];
@@ -708,6 +708,7 @@
//free arrays
fieldMappingArray = nil;
importArray = nil;
+
}
// Import finished Growl notification
@@ -804,7 +805,8 @@
*/
- (BOOL)dumpSelectedTablesAsSqlToFileHandle:(NSFileHandle *)fileHandle
{
- int i,j,t,rowCount, colCount, progressBarWidth, lastProgressValue, queryLength, tableType;
+ int i,j,t,rowCount, colCount, progressBarWidth, lastProgressValue, queryLength;
+ int tableType = SP_TABLETYPE_TABLE; //real tableType will be setup later
CMMCPResult *queryResult;
NSString *tableName, *tableColumnTypeGrouping, *previousConnectionEncoding;
NSArray *fieldNames;
@@ -825,7 +827,7 @@
[errorsView displayIfNeeded];
[singleProgressText setStringValue:NSLocalizedString(@"Dumping...", @"text showing that app is writing dump")];
[singleProgressText displayIfNeeded];
- progressBarWidth = (int)[singleProgressBar bounds].size.width;
+ //progressBarWidth = (int)[singleProgressBar bounds].size.width;
[singleProgressBar setDoubleValue:0];
[singleProgressBar displayIfNeeded];
@@ -1283,7 +1285,7 @@
lineEndString = [NSString stringWithString:tempLineEndString];
// Updating the progress bar can take >20% of processing time - store details to only update when required
- progressBarWidth = (int)[singleProgressBar bounds].size.width;
+ //progressBarWidth = (int)[singleProgressBar bounds].size.width;
lastProgressValue = 0;
[singleProgressBar setDoubleValue:0];
[singleProgressBar displayIfNeeded];
@@ -1605,7 +1607,7 @@
if (queryResult != nil && [queryResult numOfRows]) [queryResult dataSeek:0];
// Updating the progress bar can take >20% of processing time - store details to only update when required
- progressBarWidth = (int)[singleProgressBar bounds].size.width;
+ //progressBarWidth = (int)[singleProgressBar bounds].size.width;
lastProgressValue = 0;
[singleProgressBar setDoubleValue:0];
[singleProgressBar displayIfNeeded];
@@ -2042,6 +2044,7 @@
[[exportDumpTableView tableColumnWithIdentifier:@"switch"] setDataCell:switchButton];
[[exportMultipleCSVTableView tableColumnWithIdentifier:@"switch"] setDataCell:switchButton];
[[exportMultipleXMLTableView tableColumnWithIdentifier:@"switch"] setDataCell:switchButton];
+ [switchButton release];
if ( [prefs boolForKey:@"UseMonospacedFonts"] ) {
[[[exportDumpTableView tableColumnWithIdentifier:@"tables"] dataCell]
setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]];
diff --git a/Source/TablesList.m b/Source/TablesList.m
index 716727d8..b5536fd9 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -482,15 +482,15 @@
[scanner scanUpToString:@"AS" intoString:nil];
[scanner scanUpToString:@"" intoString:&scanString];
[mySQLConnection queryString:[NSString stringWithFormat:@"CREATE VIEW %@ %@", [[copyTableNameField stringValue] backtickQuotedString], scanString]];
- [scanner release];
}
else if(tblType == SP_TABLETYPE_TABLE){
[scanner initWithString:[[queryResult fetchRowAsDictionary] objectForKey:@"Create Table"]];
[scanner scanUpToString:@"(" intoString:nil];
[scanner scanUpToString:@"" intoString:&scanString];
[mySQLConnection queryString:[NSString stringWithFormat:@"CREATE TABLE %@ %@", [[copyTableNameField stringValue] backtickQuotedString], scanString]];
- [scanner release];
}
+ [scanner release];
+
else if(tblType == SP_TABLETYPE_FUNC || tblType == SP_TABLETYPE_PROC)
{
// get the create syntax
@@ -516,7 +516,9 @@
tableSyntax = [[NSString alloc] initWithData:tableSyntax encoding:[mySQLConnection encoding]];
// replace the old name by the new one and drop the old one
- theResult = [mySQLConnection queryString:[tableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(?<=%@ )(`[^`]+?`)", [tableType uppercaseString]] withString:[[copyTableNameField stringValue] backtickQuotedString]]];
+ [mySQLConnection queryString:[tableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(?<=%@ )(`[^`]+?`)", [tableType uppercaseString]] withString:[[copyTableNameField stringValue] backtickQuotedString]]];
+ [tableSyntax release];
+
if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"Couldn't duplicate '%@'.\nMySQL said: %@", @"message of panel when an item cannot be renamed"), [copyTableNameField stringValue], [mySQLConnection getLastErrorMessage]]);
@@ -651,7 +653,8 @@
tableSyntax = [[NSString alloc] initWithData:tableSyntax encoding:[mySQLConnection encoding]];
// replace the old name by the new one and drop the old one
- theResult = [mySQLConnection queryString:[tableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(?<=%@ )(`[^`]+?`)", [tableType uppercaseString]] withString:[[tableRenameField stringValue] backtickQuotedString]]];
+ [mySQLConnection queryString:[tableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(?<=%@ )(`[^`]+?`)", [tableType uppercaseString]] withString:[[tableRenameField stringValue] backtickQuotedString]]];
+ [tableSyntax release];
if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
if ([mySQLConnection isConnected]) {
[mySQLConnection queryString: [NSString stringWithFormat: @"DROP %@ %@", tableType, [[self tableName] backtickQuotedString]]];
@@ -983,7 +986,9 @@
tableSyntax = [[NSString alloc] initWithData:tableSyntax encoding:[mySQLConnection encoding]];
// replace the old name by the new one and drop the old one
- theResult = [mySQLConnection queryString:[tableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(?<=%@ )(`[^`]+?`)", tableType] withString:[anObject backtickQuotedString]]];
+ [mySQLConnection queryString:[tableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(?<=%@ )(`[^`]+?`)", tableType] withString:[anObject backtickQuotedString]]];
+ [tableSyntax release];
+
if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
if ([mySQLConnection isConnected]) {
[mySQLConnection queryString: [NSString stringWithFormat: @"DROP %@ %@", tableType, [[tables objectAtIndex:rowIndex] backtickQuotedString]]];
diff --git a/Source/TunnelPassphraseRequester.m b/Source/TunnelPassphraseRequester.m
index 360af00d..fb44a400 100644
--- a/Source/TunnelPassphraseRequester.m
+++ b/Source/TunnelPassphraseRequester.m
@@ -47,6 +47,7 @@ int main(int argc, const char *argv[])
sequelProTunnel = (SPSSHTunnel *)[NSConnection rootProxyForConnectionWithRegisteredName:connectionName host:nil];
if (!sequelProTunnel) {
NSLog(@"SSH Tunnel: unable to connect to Sequel Pro to show SSH question");
+ [argument release];
[pool release];
return 1;
}
@@ -57,6 +58,7 @@ int main(int argc, const char *argv[])
printf("no\n");
}
[pool release];
+ [argument release];
return 0;
}
@@ -114,6 +116,7 @@ int main(int argc, const char *argv[])
printf("%s\n", [password UTF8String]);
[pool release];
+ [argument release];
return 0;
}
}
@@ -125,6 +128,7 @@ int main(int argc, const char *argv[])
if (!verificationHash) {
NSLog(@"SSH Tunnel: key passphrase authentication required but insufficient details supplied to connect to GUI");
[pool release];
+ [argument release];
return 1;
}
@@ -132,19 +136,23 @@ int main(int argc, const char *argv[])
if (!sequelProTunnel) {
NSLog(@"SSH Tunnel: unable to connect to Sequel Pro to show SSH question");
[pool release];
+ [argument release];
return 1;
}
passphrase = [sequelProTunnel getPasswordForQuery:argument verificationHash:verificationHash];
if (!passphrase) {
[pool release];
+ [argument release];
return 1;
}
printf("%s\n", [passphrase UTF8String]);
[pool release];
+ [argument release];
return 0;
}
[pool release];
+ [argument release];
return 1;
-} \ No newline at end of file
+}