• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can't keep from leaking memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't keep from leaking memory


  • Subject: Re: Can't keep from leaking memory
  • From: Shaun Wexler <email@hidden>
  • Date: Sat, 25 Jun 2005 18:13:23 -0700

On Jun 24, 2005, at 11:11 PM, Lee Morgan wrote:

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?

- (NSData *)someData
{
NSData *someData;
if ((someData = [otherData copy]) || (someData = [someOtherData copy])) {
[someData autorelease];
}
return someData;
}
--
Shaun Wexler
MacFOH
http://www.macfoh.com



_______________________________________________ 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
References: 
 >Can't keep from leaking memory (From: Lee Morgan <email@hidden>)

  • Prev by Date: Re: Better way to launch applications in Cocoa
  • Next by Date: Re: Class clusters - infinite loop?
  • Previous by thread: Re: Can't keep from leaking memory
  • Next by thread: Re: Can't keep from leaking memory
  • Index(es):
    • Date
    • Thread