• 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: Dave Geering <email@hidden>
  • Date: Fri, 24 Apr 2009 11:17:51 +1000

On Fri, Apr 24, 2009 at 6:42 AM, Todd Heberlein <email@hidden> wrote:
> For example, will
>
> foo2( CFSTR("bar") ); or
> foo2 ( CFStringCreateWithCString(NULL, "bar", kCFStringEncodingASCII) );
>
> leak memory?

The first won't, but the second will. It's similar to taking the
[[NSString alloc] initWithCString:] route. All Core Foundation creator
functions with Create or Copy in the name leave you with the
responsibility of releasing the return value when you're done with it.

There's a relatively new CFMakeCollectable() function which marks a
Core Foundation type as collectable by the garbage collector, but I
have no experience with it.
_______________________________________________

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>)

  • Prev by Date: Re: Best practice regarding display of many similar items in a lengthy view
  • Next by Date: Re: CF autorelease?
  • Previous by thread: Re: CF autorelease?
  • Next by thread: Re: CF autorelease?
  • Index(es):
    • Date
    • Thread