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


GetPtrSize

You can use the GetPtrSize function to find out the logical size of the nonrelocatable block corresponding to a pointer.

FUNCTION GetPtrSize (p: Ptr): Size;
p
A pointer to a nonrelocatable block.
DESCRIPTION
The GetPtrSize function returns the logical size, in bytes, of the nonrelocatable block pointed to by p. In case of an error, GetPtrSize returns 0.

ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit for GetPtrSize are
Registers on entry
A0Pointer to the nonrelocatable block
Registers on exit
D0If >=0, number of bytes in nonrelocatable 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 _GetPtrSize 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.

RESULT CODES
noErr0No error
memWZErr-111Attempt to operate on a free block

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996