At 04:27 AM 6/8/2004, you wrote:
I've been getting errors in an application, invoked via SysUIAppSwitch(),
when it frees the cmdPBP passed by the caller.  The caller calls
MemPtrSetOwner(ptr, 0); before calling SysUIAppSwitch() or during its
AppStop() handling (or both). It appears that if a value is passed as
cmdPBP, it must be a pointer and it should not be freed by the receiving
application.  Either of these cases results in the system failing (during
the switch if the value is a MemHandle rather than MemPtr, for example, and
after the called application exits, in the second case).

Can someone substantiate my assumptions?

Yes. When you pass a pointer to SysUIAppSwitch, you've given control of it to the OS, and the OS is responsible for deallocating it. That's why it's important to set the owner to 0 -- otherwise, the system routine that frees all of the memory allocated by a program when it ends would free this block before the new program is called.



-- Ben Combee, DTS technical lead, PalmSource, Inc. Read "Combee on Palm OS" at http://palmos.combee.net/



--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to