Important: The information in this document is obsolete and should not be used for new development.
NewPtr
You can use theNewPtrfunction to allocate a nonrelocatable block of memory of a specified size.
FUNCTION NewPtr (logicalSize: Size): Ptr;
logicalSize- The requested size (in bytes) of the nonrelocatable block.
DESCRIPTION
TheNewPtrfunction attempts to allocate, in the current heap zone, a nonrelocatable block with a logical size oflogicalSizebytes and then return a pointer to the block. If the requested number of bytes cannot be allocated,NewPtrreturnsNIL.The
NewPtrfunction attempts to reserve space as low in the heap zone as possible for the new block. If it is able to reserve the requested amount of space,NewPtrallocates the nonrelocatable block in the gapReserveMemcreates. Otherwise,NewPtrreturnsNILand generates amemFullErrerror.SPECIAL CONSIDERATIONS
BecauseNewPtrallocates memory, you should not call it at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit forNewPtrare
Registers on entry A0 Number of logical bytes requested
Registers on exit A0 Address of the new block or NILD0 Result code If you want to clear the bytes of a block of memory to 0 when you allocate it with the
NewPtrfunction, set bit 9 of the routine trap word. You can usually do this by supplying the wordCLEARas the second argument to the routine macro, as follows:
_NewPtr ,CLEARRESULT CODES
noErr 0 No error memFullErr -108 Not enough memory