Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!wuarchive!udel!haven!mimsy!mojo!russotto From: russotto@eng.umd.edu (Matthew T. Russotto) Newsgroups: comp.sys.mac.programmer Subject: Re: 32-bit Cleanliness Message-ID: <1991Jan8.012444.4466@eng.umd.edu> Date: 8 Jan 91 01:24:44 GMT References: <29193@usc> Sender: news@eng.umd.edu (C-News) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 36 In article <29193@usc> dank@calvin.usc.edu (Dan King) writes: > >I've got a question on the Politically Correct way to dereference a >resource. > >Example (using C-ish syntax): >I call GetResource(blah) to get a handle to the resource. I then >Detach() it and HLock() it. What should I do to dereference it? >Should I kill the upper 8 bits (I don't think so), should I >StripAddress it (TN212 says not, but who knows?), or should I just go >ahead and dereference it (Ptr x; x=*handle;)? HELP!!!! Handles should never need to be StripAddress()ed. Go ahead and dereference it. > >I've read the technote on being 32-bit clean and the technote on >StripAddress. Neither really tells me (explicitly) what I need to do. >I believe that just dereferencing the handle without worrying about >the upper 8 bits will work, but doesn't the resource manager use those >for different states (like locked, purgeable, etc)? Or do those go >away when you detach the handle? Those things are in the master pointer, not the handle. There are only a few cases where you need to worry about this. One is when comparing master pointers (i.e. *foohandle > *barhandle-- why one compares master pointers I don't know...) . Another is if you are on a machine with a 24 bit memory manager running and you use SwapMMUMode to go to 32 bit mode. All dereferences of master pointers when you have the MMUMode at 32 bits must be StripAddressed > >Thanks for putting up with boring questions, >dank -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu .sig under construction, like the rest of this campus.