Xref: utzoo comp.sys.mac.programmer:5518 comp.sys.mac.hypercard:1807 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!oren@apple.com From: oren@apple.com (Tim Oren) Newsgroups: comp.sys.mac.programmer,comp.sys.mac.hypercard Subject: Re: XFCN/XCMD string in MPW C v3.0 Message-ID: <1264@internal.Apple.COM> Date: 10 Apr 89 18:31:39 GMT Sender: usenet@Apple.COM Organization: Apple Computer Advanced Technology Lines: 23 References: <28684@apple.Apple.COM> In article <28684@apple.Apple.COM> austing@Apple.COM (Glenn L. Austin) writes: > If you compile with the -b option on MPW C, the strings are referenced off > of the PC, which means that you don't need to worry about strings. However, > global variables are out. We've found a way to get the effect of globals. In the same stack where the XCMD lives, create a dummy resource with known name and type, e.g., STUB 1. When the XCMD runs the first time, load the resource, detach it, mark it non-purgable and grow it to whatever size you need for your data, then do any initialization. On following calls, get the resources handle by name to reacquire your "globals". The overhead of the resource manager could make this too slow if your XCMD is called from an inner loop. For a slight speedup, lock the resource when entering the XCMD and dereference the handle to address things. Unlock it before exiting to avoid sandbarring the memory manager. Tim Oren oren@apple.com "As always, if you are caught or killed, the CEO will disavow all knowledge of your actions."