Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ames!amdahl!uunet!hodge!pnet06!thecloud From: thecloud@pnet06.cts.com (Ken Mcleod) Newsgroups: comp.sys.mac.programmer Subject: Re: Question on Handle locking example Message-ID: <5972@hodge.UUCP> Date: 28 Jan 89 10:17:19 GMT Sender: root@hodge.UUCP Organization: People-Net [pnet06], Orange, CA Lines: 25 uucibg@sw1e.UUCP ([5-3929] Brian Gilstrap) writes: > >I'm not clear on why function 'a' below would die. This was posted recently >as an example of how not to code. I'm sure I'm missing something extremely >obvious (it's late...), but please explain.... >a() >{ > HLock(h); > b(h); > *h->x = ... /* this would not survive a heap scramble */ > HUnlock(h); >} The 'obvious' portion was in function 'b', which unlocked the handle 'h' before returning. Therefore, at the time h is dereferenced, the handle is unlocked! There's nothing wrong with function 'a' as posted above, which was the whole moral of this story: watch your HLock's and HUnlock's very carefully! ========== ....... =================================== ============ Ken McLeod :. .: UUCP: {crash uunet}!pnet06!thecloud "They mean ---------- :::.. ..::: InterNet: thecloud@pnet06.cts.com to win !(C)1988 //// or thecloud@dhw68k.cts.com Wimbledon!"