• 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: Allocation and disposal inside a loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Allocation and disposal inside a loop


  • Subject: Re: Allocation and disposal inside a loop
  • From: Nathan Day <email@hidden>
  • Date: Tue, 4 Feb 2003 17:34:58 +1030

you will get a memory leak if both init methods fail. The release only lets go of your hold of an object, but the addObject method will retain them it's self so thats not a problem.

On Tuesday, February 4, 2003, at 03:38 PM, Ken Tozier wrote:

NSMutableArray *theArray = [[NSMutableArray alloc] init];
MyClass *tempObj;

while (startPtr < endPtr)
{
tempObj = [MyClass alloc];
if ([tempObj initializer1:&startPtr end:endPtr] != nil)
[theArray addObject:tempObject];
else if ([tempObj initializer2:&startPtr end:endPtr] != nil)
[theArray addObject:tempObject];
else break;

startPtr += [tempObj length];
[tempObject release];
}


Nathan Day
http://homepage.mac.com/nathan_day/
_______________________________________________
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.

References: 
 >Allocation and disposal inside a loop (From: Ken Tozier <email@hidden>)

  • Prev by Date: From header and NSMailDelivery (was Re: Sending Email with Attachments)
  • Next by Date: Programatically setting resize springs
  • Previous by thread: Allocation and disposal inside a loop
  • Next by thread: Re: Allocation and disposal inside a loop
  • Index(es):
    • Date
    • Thread