Re: Can't keep from leaking memory
Re: Can't keep from leaking memory
- Subject: Re: Can't keep from leaking memory
- From: Frédéric Testuz <email@hidden>
- Date: Sat, 25 Jun 2005 08:17:22 +0200
Le 25 juin 05, à 08:11, Lee Morgan a écrit :
OK, I'm feeling dumb tonight...
No matter what I try I can't keep this from leaking memory
- (NSData*)someData {
NSData *someData = [[NSData alloc] initWithData:otherData];
if (someData == nil)
someData = [[NSData alloc] initWithData:someOtherData];
return [[someData retain] autorelease];
}
Despite what I try if someData == nil during that call it will end up
leaking.
Any thoughts on how to correct this?
Well, after a -init... method, you already own the object. So why do
you send a -retain message before returning it ?
--
Frédéric Testuz
<mailto:email@hidden>
_______________________________________________
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