Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!cornell!uw-beaver!microsoft!t-benw From: t-benw@microsoft.UUCP (Benjamin Waldmin) Newsgroups: comp.sys.mac.programmer Subject: Re: sharing data between cdevs and INITs Keywords: INIT cdev LSC DRVR Message-ID: <1749@microsoft.UUCP> Date: 23 Aug 88 18:16:37 GMT References: <1739@microsoft.UUCP> <15808@apple.Apple.COM> <1745@microsoft.UUCP> <2413@spray.CalComp.COM> Reply-To: t-benw@microsoft.uucp (Benjamin Waldman) Organization: Microsoft Corporation, Redmond, WA Lines: 32 In article <2413@spray.CalComp.COM> anson@spray.UUCP (Ed Anson) writes: >In article <1745@microsoft.UUCP> t-benw@microsoft.uucp (Benjamin Waldman) writes: >>But, wait, it gets worse. Think C lets you have global data in your >>drivers by allocating a block in the heap for you, locking it, pointing >>A4 to it, and referencing your globals off of A4. But my data has to >>be in the system heap!!! > >When you allocate globals for a driver, they are stored in a DATA resource. >You could try just setting the System bit for that resource. It may solve >your problem. > >Im not sure, but it looks like LSC is using GetResource, not NewHandle. Actually, someone from THINK mailed me a neat suggestion (the day after my posting - how's that for customer service!). Since my driver is being opened by an INIT, I can just save the current zone, set the zone to be the system heap, and open my driver. Since the system heap will be the current zone when the driver is opened, both it and its data will be in the system heap. Finally I restore the old zone. Since I do want to keep the driver in memory though, and not close it when the INIT is closed, I do a GetResource('DRVR',theID), OpenDriver(...), and a DetachResource. Still though, if I wasn't opening the driver at INIT time, I'd have to go and manually set the bits with ResEdit every time I rebuilt the driver, which is a pain. I guess this is just a small oversight on THINK's part, which, one hopes, will be corrected in the next release. Ben Waldman Software Design Engineer, Microsoft Corp. Disclaimer: These are my thoughts, opinions, and ideas only, and do not reflect those of my employer in any way.