Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Memory /
Chapter 2 - Memory Manager / Memory Manager Reference
Memory Manager Routines / Setting the Properties of Relocatable Blocks


HLock

You can use the HLock 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
The HLock procedure locks the relocatable block to which h 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 for HLock are
Registers on entry
A0Handle to lock
Registers on exit
D0Result code

RESULT CODES
noErr0No error
nilHandleErr-109NIL master pointer
memWZErr-111Attempt 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 the ReserveMem 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.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996