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 / Changing the Sizes of Relocatable and Nonrelocatable Blocks


GetHandleSize

You can use the GetHandleSize function to find out the logical size of the relocatable block corresponding to a handle.

FUNCTION GetHandleSize (h: Handle): Size;
h
A handle to a relocatable block.
DESCRIPTION
The GetHandleSize function returns the logical size, in bytes, of the relocatable block whose handle is h. In case of an error, GetHandleSize returns 0.

ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit for GetHandleSize are
Registers on entry
A0Handle to the relocatable block
Registers on exit
D0If >=0, number of bytes in relocatable block
 If <0, result code

The trap dispatcher sets the condition codes before returning from a trap by testing the low-order word of register D0 with a TST.W instruction. Because the block size returned in D0 by _GetHandleSize is a full 32-bit long word, the word-length test sets the condition codes incorrectly in this case. To branch on the contents of D0, use your own TST.L instruction on return from the trap to test the full 32 bits of the register.

SPECIAL CONSIDERATIONS
You shouldn't call GetHandleSize at interrupt time because the heap might be in an inconsistent state.

RESULT CODES
noErr0No error
nilHandleErr-109NIL master pointer
memWZErr-111Attempt to operate on a free block

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996