• 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: CF autorelease?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CF autorelease?


  • Subject: Re: CF autorelease?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sat, 25 Apr 2009 10:36:06 +0200


Le 25 avr. 09 à 07:57, Charles Srstka a écrit :

On Apr 23, 2009, at 3:42 PM, Todd Heberlein wrote:

Many of the Cocoa object allocation methods automatically do an autorelease before returning the pointer to the object, so I can call something like:

foo( [NSString stringWithCString: "bar" encoding: NSASCIIStringEncoding] );

and then not worry about memory leakage. Is the same true with Core Foundation calls? For example, will

foo2( CFSTR("bar") ); or
foo2 ( CFStringCreateWithCString(NULL, "bar", kCFStringEncodingASCII) );


leak memory?

You could just:

foo2 ( [(NSString *)CFStringCreateWithCString(NULL, "bar", kCFStringEncodingASCII) autorelease] );

To be GC safe, it should be

foo2 ( [NSMakeColectable(CFStringCreateWithCString(NULL, "bar", kCFStringEncodingASCII)) autorelease] );


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >CF autorelease? (From: Todd Heberlein <email@hidden>)
 >Re: CF autorelease? (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Conversation-style controls?
  • Next by Date: Re: Conversation-style controls?
  • Previous by thread: Re: CF autorelease?
  • Next by thread: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize
  • Index(es):
    • Date
    • Thread