Important: The information in this document is obsolete and should not be used for new development.
HLock
You can use theHLock
procedure to lock a relocatable block so that it does not move in the heap. If you plan to dereference a handle and then allocate, move, or purge memory (or call a routine that does so), then you should lock the handle before using the dereferenced handle.
PROCEDURE HLock (h: Handle);
h
- A handle to a relocatable block.
DESCRIPTION
TheHLock
procedure locks the relocatable block to whichh
is a handle, preventing it from being moved within its heap zone. If the block is already locked,HLock
does nothing.ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit forHLock
are
Registers on entry A0 Handle to lock
Registers on exit D0 Result code RESULT CODES
noErr 0 No error nilHandleErr -109 NIL
master pointermemWZErr -111 Attempt to operate on a free block SEE ALSO
If you plan to lock a relocatable block for long periods of time, you can prevent fragmentation by ensuring that the block is as low as possible in the heap zone. To do this, see the description of theReserveMem
procedure on page 2-55.If you plan to lock a relocatable block for short periods of time, you can prevent heap fragmentation by moving the block to the top of the heap zone before locking. For more information, see the description of the
MoveHHi
procedure on page 2-56.