Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFM to Mach-O Conversion Crash in CodeWarrior (SOLVED)




On Oct 26, 2005, at 5:39 PM, Mark D. Gerl wrote:

So, here's the code that WORKS in CFM and FAILS in MachO:

    // cache our App-level resource file
    CFBundleRef auxAppBundle(::CFBundleGetMainBundle());

    // extract type and creator codes from it
    UInt32 auxCreator;
    ::CFBundleGetPackageInfo(auxAppBundle, NULL, &auxCreator);

    StResource appRes(auxCreator, (ResIDT)0);    // could throw
    mAppResFile = ::HomeResFile(appRes.Get());

    // cleanup (FAILS in Mach-O) ##############################
    #if TARGET_RT_MAC_CFM
        ::CFRelease(auxAppBundle);
    #endif

What's the right thing to do here - release or not??? Is this a bug in my logic (and ignored in CFM) but brought to the surface in MachO?

As John Stiles said, this is absolutely incorrect in both CFM and mach-o. You should not release auxAppBundle for either build.


When using CoreFoundation API, anything that is returned by an API with "Get" in the name does not need to be released, and anything returned by an API with "Create" or "Copy" in the name does need to be released.

You were just getting lucky that this didn't crash in CFM - probably a few more or fewer heap blocks were allocated in the CFM case, just enough to change the allocation pattern.

-eric

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >CFM to Mach-O Conversion Crash in CodeWarrior (From: "Mark D. Gerl" <email@hidden>)
 >Re: CFM to Mach-O Conversion Crash in CodeWarrior (From: "Mark D. Gerl" <email@hidden>)
 >Re: CFM to Mach-O Conversion Crash in CodeWarrior (From: Eric Schlegel <email@hidden>)
 >Re: CFM to Mach-O Conversion Crash in CodeWarrior (SOLVED) (From: "Mark D. Gerl" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.