Microsoft KB Archive/45425
Article ID: 45425
Article Last Modified on 1/8/2003
- Microsoft QuickBasic Compiler for Macintosh 1.0
This article was previously published under Q45425
The following information applies to Microsoft QuickBASIC Version 1.00 for the Apple Macintosh.
The following code shows how to release memory occupied by a nonrelocatable block of memory that was previously allocated by the NewPtr Toolbox function. How to call the NewPtr Toolbox is described in another article in this knowledgebase (query on NewPtr Toolbox).
After the call to the DisposPtr function, all pointers to the released block become invalid and should not be used again. Calling DisposPtr using invalid pointers may damage the master pointer list.
The following example uses one of two new ToolBox routines, which are explained in a separate article in this knowledgebase (query on ToolBoxNewOS and ToolboxNewTOOL). The NewPtr Toolbox call must be called before the DisposPtr Toolbox call to allocate a block of memory and return a pointer to the variable PointerValue. This variable is then passed to the DisposPtr Toolbox call to free the block of memory. If DisposPtr is successful, the DisposPtr Toolbox call returns an error code of (0) zero.
DIM RegsArray&(5) DisposPtr& = &HA01F 'TRAP number for the function. a0& = PointerValue 'PointerValue is the pointer returned 'by the NewPtr function. ToolBoxNewOS "i" 'initialized the ToolBox call. ToolBoxNewOS "r",DisposPtr&,RegsArray&(0),(a0&) 'calls DisposPtr 'function. PRINT "This is the error code: 0 if all goes well", RegsArray(2)
Additional query words: MQuickB