Problems with double freeing.
Problems with double freeing.
- Subject: Problems with double freeing.
- From: Tom Jones <email@hidden>
- Date: Sun, 20 Nov 2005 08:45:22 -0600
Sorry for the lengthy code snippet. For some reason this code exits
with the following entries in the log
2005-11-20 08:18:46.377 Playlist Page Maker[10525] *** -[NSCFString
characterAtIndex:]: Range or index out of bounds
Playlist Page Maker(10525) malloc: *** error for object 0x3a90f0: double free
Playlist Page Maker(10525) malloc: *** set a breakpoint in szone_error to debug
Playlist Page Maker(10525) malloc: *** error for object 0x3a5e80: double free
Playlist Page Maker(10525) malloc: *** set a breakpoint in szone_error to debug
I guess this means I've released something I should have retained or
vice-versa. The code exits after this loop: for (i = 0; i< [theHeaders
count]; i++) loop.
Application does not crash.
I tried adding an szone_error breakpoint(double clicked on Symbol ,
typed szone_error), but it did not break on it.
Any help would be appreciated.
Thanks,
Tom
Here's the code:
NSString* fileName = @"/Users/tom/Documents/untitled playlist.txt";
while([[tableView tableColumns] count] >0)
[tableView removeTableColumn:[[tableView tableColumns]objectAtIndex:0]];
NSArray * theLines = [[[NSString stringWithContentsOfFile:
fileName/*[openPanel filename]*/]
componentsSeparatedByString:@"\r"]autorelease];
int i;
if ([theLines count] > 0 )
{
[tableView setColumnAutoresizingStyle:NSTableViewSequentialColumnAutoresizingStyle];
NSArray * theHeaders = [[theLines objectAtIndex:0]
componentsSeparatedByString:@"\t"];
for (i = 0; i< [theHeaders count]; i++)
{
NSTableColumn *newColumn;
newColumn = [[[NSTableColumn alloc]initWithIdentifier:[theHeaders
objectAtIndex:i]] autorelease];
[[newColumn headerCell] setStringValue:[theHeaders objectAtIndex:i]];
[tableView addTableColumn:newColumn];
ItemAttributes* itemAttribute = [[[ ItemAttributes alloc]init]autorelease];
[playlist setObject:itemAttribute forKey:[theHeaders objectAtIndex:i]];
}//exits after executing next line (possibly before)
[columnName setStringValue:[theHeaders objectAtIndex:0]];
NSString * test = [[columnName stringValue] copy];
i = [theLines count];
for (i = 1; i < 12; i++)
{
NSArray * theColumns = [[[theLines objectAtIndex:i]
componentsSeparatedByString:@"\t"] autorelease];
int shortestArray;
if ([theColumns count] > [theHeaders count])
{
shortestArray = [theHeaders count];
}
else
{
shortestArray = [theColumns count];
}
int columnIndex;
for (columnIndex = 0; columnIndex < shortestArray; columnIndex++)
{
ItemAttributes* attr =[playlist valueForKey:[theHeaders
objectAtIndex:columnIndex]];
[[attr listOfItems] addObject:[theColumns objectAtIndex:columnIndex]];
}
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden