Important: The information in this document is obsolete and should not be used for new development.
HLock
You can use theHLockprocedure 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
TheHLockprocedure locks the relocatable block to whichhis a handle, preventing it from being moved within its heap zone. If the block is already locked,HLockdoes nothing.ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit forHLockare
Registers on entry A0 Handle to lock
Registers on exit D0 Result code RESULT CODES
noErr 0 No error nilHandleErr -109 NILmaster 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 theReserveMemprocedure on page 1-70.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
MoveHHiprocedure on page 1-71.