Re: Fixing a leak in an NSFormatter
Re: Fixing a leak in an NSFormatter
- Subject: Re: Fixing a leak in an NSFormatter
- From: Darrin Cardani <email@hidden>
- Date: Wed, 7 Apr 2004 15:39:34 -0500
At 10:26 PM +0200 4/7/04, Stiphane Sudre wrote:
It's a bit surprising it's not crashing a bit later
How is it surprising? Are you implying that I'm double releasing something?
- (NSAttributedString*)attributedStringForObjectValue:(id)anObject
withDefaultAttributes:(NSDictionary*)attributes
{
// Get the non-formatted string
NSString* regularString = [ self stringForObjectValue:anObject ];
...
// Create an attributed string from the non-formatted one,
//but add our attributes
retVal = [ [ NSAttributedString alloc ]
initWithString:regularString attributes:newAttribs ];
// Clean up
[ newAttribs release ];
[ regularString autorelease ];
Why do you want to release regularString? It's already autoreleased.
Why do you say it's already autoreleased? Doesn't
that depend on how I created it in
-stringForObjectValue: ?
The ending code should be AFAIK:
[ newAttribs release ];
return [retVal autorelease];
When I do that, I get a crash when the next
autorelease pool releases its objects.
Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<
http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.