Important: The information in this document is obsolete and should not be used for new development.
HandToHand
Use theHandToHand
function to copy all of the data from one relocatable block to a new relocatable block.
FUNCTION HandToHand (VAR theHndl: Handle): OSErr;
theHndl
- On entry, a handle to the relocatable block whose data is to be copied. On exit, a handle to a new relocatable block whose data duplicates that of
the original.DESCRIPTION
TheHandToHand
function attempts to copy the information in the relocatable block to whichtheHndl
is a handle; if successful,HandToHand
returns a handle to the new relocatable block intheHndl
. The new relocatable block is created in the same heap zone as the original block (which might not be the current heap zone).Because
HandToHand
replaces its input parameter with the new handle, you should retain the original value of the input parameter somewhere else, or you won't be able to access it. Here is an example:
VAR original, copy: Handle; myErr: OSErr; ... copy := original; {both handles access same block} myErr := HandToHand(copy); {copy now points to copy of block}SPECIAL CONSIDERATIONS
If successful in creating a new relocatable block, theHandToHand
function does not duplicate the properties of the original block. The new block is unlocked, unpurgeable, and not a resource. You might need to callHLock
,HPurge
, orHSetRBit
(or the combination ofHGetState
andHSetState
) to adjust the properties of the new block.Because
HandToHand
allocates memory, you should not call it at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit forHandToHand
are
Registers on entry A0 Handle to original data
Registers on exit A0 Handle to copy of data D0 Result code RESULT CODES
noErr 0 No error memFullErr -108 Not enough memory nilHandleErr -109 NIL
master pointermemWZErr -111 Attempt to operate on a free block SEE ALSO
If you want to copy only part of a relocatable block into a new relocatable block, use thePtrToHand
function, described on page 2-60, after locking and dereferencing a handle to the relocatable block to be copied.