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 1 - Introduction to Memory Management / Memory Management Reference
Memory Management Routines / Managing Relocatable Blocks


ReallocateHandle

To recover space for a relocatable block that you have emptied or the Memory Manager has purged, use the ReallocateHandle procedure.

PROCEDURE ReallocateHandle (h: Handle; logicalSize: Size);
h
A handle to a relocatable block.
logicalSize
The desired new logical size (in bytes) of the relocatable block.
DESCRIPTION
The ReallocateHandle procedure allocates a new relocatable block with a logical size of logicalSize bytes. It updates the handle h by setting its master pointer to point to the new block. The new block is unlocked and unpurgeable.

Usually you use ReallocateHandle to reallocate space for a block that you have emptied or the Memory Manager has purged. If the handle references an existing block, ReallocateHandle releases that block before creating a new one.

Note
To reallocate space for a resource that has been purged, you should call LoadResource, not ReallocateHandle.
If many handles reference a single purged, relocatable block, you need to call ReallocateHandle on just one of them.

In case of an error, ReallocateHandle neither allocates a new block nor changes the master pointer to which handle h points.

SPECIAL CONSIDERATIONS
Because ReallocateHandle might purge and allocate memory, you should not call it at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit for ReallocateHandle are
Registers on entry
A0Handle for new relocatable block
D0Desired logical size, in bytes, of new block
Registers on exit
D0Result code

RESULT CODES
noErr0No error
memROZErr-99Heap zone is read-only
memFullErr-108Not enough memory
memWZErr-111Attempt to operate on a free block
memPurErr-112Attempt to purge a locked block

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996