Re: CF autorelease?
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