🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #20352

Re: When to HLock

#20352
From: <10000>Bob Lemley
Date: Wed, 14 Oct 1987 22:19
28 lines
1591 bytes
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
Technical Details
Message-ID: <326@lznh.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!sri-unix!sri-spam!mordor!lll-lcc!ptsfa!ihnp4!homxb!mtuxo!mtune!lzaz!lznh!bob
References: <960@mntgfx.MENTOR.COM>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!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.