• 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: Re(2): Strange crash, CFBundle*
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re(2): Strange crash, CFBundle*


  • Subject: Re: Re(2): Strange crash, CFBundle*
  • From: Dan Wood <email@hidden>
  • Date: Tue, 11 Dec 2001 11:23:10 -0800

Douglas, is this also the case with NSBundles? I'm currently working on a problem where I'm trying to completely deallocate an NSBundle (because the version on disk has been updated to a new version), and then load it again. Maybe this "unique-ing" is getting in the way. Any way to cause a bundle to be re-fetched from disk?

Dan Wood



On Tuesday, December 11, 2001, at 09:16 AM, Douglas Davidson wrote:

On Tuesday, December 11, 2001, at 12:31 AM, Jens Bauer wrote:

Here's a shortened down version of code I did not write myself:

static bool myfunction()
{
CFBundleRef bundle;
CFURLRef resources;

bundle = CFBundleGetMainBundle();

if(!bundle)
{
return(FALSE);
}

resources = CFBundleCopyResourcesDirectoryURL(bundle);
--> CFRelease(bundle);

if(!resources)
{
return(FALSE);
}
...
...
}



You mention that I should not release something that was returned to me by a
"get" function. Is the above CFRelease(bundle) wrong then ?

Yes! You will see random crashes if you release the result of CFBundleGetMainBundle().

Remember the rules: exactly one release for each API call with "create", "copy", or "retain" in it.

One further point is that you don't actually need to release bundles that you don't want to be unloaded--and the main bundle would fall into this category. Bundle instances are uniqued, so not releasing a bundle doesn't cause a leak if that bundle wasn't going to go away.

Douglas Davidson
_______________________________________________
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.



--
Dan Wood
email@hidden
http://www.karelia.com/
Watson for Mac OS X: http://www.karelia.com/watson/


  • Follow-Ups:
    • Re: Re(2): Strange crash, CFBundle*
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: Re(2): Strange crash, CFBundle* (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: About, ReadMe, and Registration Windows
  • Next by Date: buy that new Book?
  • Previous by thread: Re(4): Strange crash, CFBundle*
  • Next by thread: Re: Re(2): Strange crash, CFBundle*
  • Index(es):
    • Date
    • Thread