Fix leaks.

This commit is contained in:
Nate Weaver 2012-07-04 23:32:34 -05:00
parent 142cdbcae6
commit 1c438e1fac
2 changed files with 7 additions and 5 deletions

View File

@ -77,6 +77,7 @@
if(*((unsigned short *)[unicodeData mutableBytes]) == 0xFEFF || *((unsigned short *)[unicodeData mutableBytes]) == 0xFFFE)
[unicodeData replaceBytesInRange:NSMakeRange(0,2) withBytes:NULL length:0];
[self editData:[[[self window] windowController] data] replaceBytesInRange:selection withData:unicodeData];
[unicodeData release];
}
}
@ -213,7 +214,7 @@ static NSRange draggedRange;
- (void)insertText:(NSString *)string
{
NSRange selection = [(HexEditorDelegate *)[self delegate] rangeForUserTextChange];
NSMutableData *data = [[[[self window] windowController] data] mutableCopy];
NSMutableData *data = [[[[[self window] windowController] data] mutableCopy] autorelease];
NSData *replaceData = [string dataUsingEncoding:NSASCIIStringEncoding];
if(self == (id) [(HexEditorDelegate *)[self delegate] hex])
@ -252,7 +253,6 @@ static NSRange draggedRange;
// replace bytes (updates views implicitly, records an undo)
[self editData:data replaceBytesInRange:selection withData:replaceData];
[data release];
// set the new selection (insertion point)
selection.location++;
@ -357,6 +357,7 @@ static NSRange draggedRange;
// record undo with new data object
[[[[self window] undoManager] prepareWithInvocationTarget:self] editData:newData replaceBytesInRange:newRange withData:oldBytes];
[oldBytes release];
[[[self window] undoManager] setActionName:NSLocalizedString(@"Typing", nil)];
if(closeUndoGroup)
[[[self window] undoManager] endUndoGrouping];

View File

@ -169,12 +169,12 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
- (void)saveResource:(id)sender
{
[backup setData:[[resource data] copy]];
[backup setData:[[[resource data] copy] autorelease]];
}
- (void)revertResource:(id)sender
{
[resource setData:[[backup data] copy]];
[resource setData:[[[backup data] copy] autorelease]];
}
- (void)showFind:(id)sender
@ -210,7 +210,7 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
else
{
// this should refresh the view automatically
[resource setData:[[object data] copy]];
[resource setData:[[[object data] copy]] autorelease];
[self setDocumentEdited:NO];
}
}
@ -230,6 +230,7 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
NSMutableParagraphStyle *paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraph setLineBreakMode:NSLineBreakByCharWrapping];
NSDictionary *dictionary = [NSDictionary dictionaryWithObject:paragraph forKey:NSParagraphStyleAttributeName];
[paragraph release];
// do stuff with data
[offset setString:[hexDelegate offsetRepresentation:data]];