Microsoft KB Archive/45425

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 16:56, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


How to Use DisposePtr Toolbox to Release NewPtr Memory Block

Article ID: 45425

Article Last Modified on 1/8/2003



APPLIES TO

  • Microsoft QuickBasic Compiler for Macintosh 1.0



This article was previously published under Q45425

SUMMARY

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).

MORE INFORMATION

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.

Code Example

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

Keywords: KB45425