Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!sri-unix!sri-spam!mordor!lll-lcc!ptsfa!ihnp4!homxb!mtuxo!mtune!lzaz!lznh!bob From: bob@lznh.UUCP (<10000>Bob Lemley) Newsgroups: comp.sys.mac Subject: Re: When to HLock Message-ID: <326@lznh.UUCP> Date: Wed, 14-Oct-87 18:19:50 EDT Article-I.D.: lznh.326 Posted: Wed Oct 14 18:19:50 1987 Date-Received: Sat, 17-Oct-87 05:10:46 EDT References: <960@mntgfx.MENTOR.COM> Organization: AT&T Lines: 28 Summary: HLock not required for double indirect assignments. In article <960@mntgfx.MENTOR.COM>, tomc@mntgfx.MENTOR.COM (Tom Carstensen) writes: > Question: Do you need to HLock in the following > kind of situation?: > > TEHandle TheText; > lines = (**TheText).nLines Answer: No, but be sure to allocate memory space for the TextEdit record via TENew() before accessing any fields of the TE record. Usually, you lock handles down only if you are both: 1) dereferencing the handle AND 2) making a call to a routine which may purge or move memory. For example, if you passed the address of an ELEMENT contained in an unlocked heap structure to a subroutine and the subroutine made a toolbox call that moved memory, the pointer you passed could become invalid (ie. point to garbage, or worse, to important system data). Usually, you should call MoveHHi after locking a handle to avoid heap fragmentation problems. Inside Mac contains an appendix of all ToolBox and OS routines which might purge or move memory. Robert C. Lemley { ihnp4 | allegra } lznh!bob