At 06:27 PM 6/15/2004, you wrote:
Many routines that use callback functions (ex. SndStreamCreate) allow the developer to have access to global data by passing a pointer to that data.
If I pass a pointer to a struct, can that struct in turn have pointers elsewhere, or does the struct always have to be self-contained?

It depends. On OS 5, a pointer should be valid all the time, so you could pass a struct pointer to SndStreamCreate that had pointers. However, you would need to make sure that the items pointed to were not moving around in memory or deallocated before the callback was finished with them.


In OS 6, its possible for some memory regions to not be mapped into all processes, so you'll have to verify that any callbacks will run in your current process, not another one. For almost all system callbacks, this is the case -- the bigger issue would be other applications that were handling notifications, potentially in a background process.

Also, can globals be used safely in gadget callback functions?

Yes, as long as globals were available in the program that setup the form with the gadgets.



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