Microsoft KB Archive/45426

= How to Allocate a Block of Heap Using NewPtr Toolbox Routine =

Article ID: 45426

Article Last Modified on 1/9/2003

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0

-



This article was previously published under Q45426



SUMMARY
The following applies to Microsoft QuickBASIC Version 1.00 for the Apple Macintosh.

The Toolbox routines for allocating and releasing heap space are contained in the Memory Manager. The NewPtr Toolbox function is used to allocate a block of memory from the heap and to return a pointer to that block. The pointer then can be used by your program to reference into that block of memory. When appropriate, the DisposPtr Toolbox function can be used to release the block the memory, as discussed in another article in this knowledgebase (query on DisposPtr and Toolbox).



MORE INFORMATION
The NewPtr Toolbox routine attempts to allocate a nonrelocatable block of memory from the current heap and if successful, return a pointer to the block. If the block cannot be allocated, NewPtr returns NUL.

The example below shows how to use the NewPtr Toolbox routine. It requires the use of one of the new ToolBox statements described in a separate article in this knowledgebase (query on &quot;ToolBoxNewTOOL&quot; or &quot;ToolBoxNewOS&quot;).

Code Example
DIM regsarray&(5) size& = 1024 Newptr& = &HA11E ToolboxNewOS &quot;I&quot; ToolboxNewOS &quot;R&quot;,NewPtr&,regsarray&(0),,,(size&)

PRINT HEX$(regsarray&(0))     'print out the pointer PRINT regsarray&(2)           'print out the error, 0 if none

Additional query words: MQuickB

Keywords: KB45426

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.