Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!pasteur!helios.ee.lbl.gov!ucsd!hub!6500stom From: 6500stom@hub.UUCP Newsgroups: comp.sys.mac.programmer Subject: Re: HLock Message-ID: <3331@hub.UUCP> Date: 16 Dec 89 06:59:47 GMT Sender: news@hub.UUCP Lines: 25 > I know this has been discussed before, but could someone tell me when > it is necessary to use HLock? If i have a handle within a CDEF do i need > to do so? What if i only access the handle thru a pointer, i.e. : > > void doSomething(theControl) > ControlHandle theControl; > { > ControlPtr cp; > > cp = *theControl; > if (cp->contrlRect ...... and so on....... It doesn't matter whether you dereference it or not in C. You might as well have done (**theControl).contrlRect instead of cp->contrlRect. The way to remember if you need to lock your handle is if you pass a field in the handle to any procedure that might move memory--even if its one of your own routines in a different segment. For example, if you do RectRgn(myRgn, (**theControl).contrlRect) you need to lock theControl down because RectRgn might move the handle before its done with the contrlRect. / Josh Pritikin T Ignorance is bliss. \ | Mail: 6500stom@ucsbuxa.ucsb.edu | I must be in hell. | | AppleLink: Josh.P | My room is proof that entropy | \ GEnie: J.Pritikin ! exists. /