Previous: 4.67.2.20. Delete procedure To the Table of Contents Next: 4.67.2.22. Eof function
4.67.2.20. Delete procedure Table of Contents 4.67.2.22. Eof function

- 4.67.2.21. -
Table of Contents
4. Standard Units
4.67. System - Built-in routines
4.67.2. System Unit Procedures and Functions
4.67.2.21. Dispose procedure


4.67.2.21. Dispose procedure

Targets: MS-DOS, OS/2, Win32


System Unit

Disposes of a dynamic variable.

Declaration:
  procedure Dispose(var P: Pointer [ , Destructor ]);
Remarks: P points to a typed variable that was previously assigned either by calling New or by an assignment. Dispose returns the allocated memory, pointed to by P, back to heap. If P does not reference heap, a run time error occurs. References to P^ after a call to Dispose results in undefined data.

Note that dynamic variables are not limited to 65,535 (64K) bytes.

Example:
type
  StrAry = Array[0..$200-1] of Char;
var
  StrPtr : ^StrAry;
begin
  New(StrPtr);
  if StrPtr = nil then 
    Halt(1);
  FillChar(StrPtr,$200,'0');
  Dispose(StrPtr);  // Release back to Heap
end.



Previous: 4.67.2.20. Delete procedure To the Table of Contents Next: 4.67.2.22. Eof function
4.67.2.20. Delete procedure Table of Contents 4.67.2.22. Eof function

- 4.67.2.21. -