HP Pascal/iX Reference Manual (31502-90022)

9- 3
.
.
new(p,engaged); { Allocates record with variant engaged.}
.
.
new(p,married); { Allocates record with variant married.}
.
.
new(p,widowed,false); { Allocates record with variants widowed
. and false.}
.
END.
dispose
Usage
dispose
(p)
dispose
(p, t1,...,tn)
Parameters
p
A pointer expression that cannot be NIL or undefined.
t
A case constant value whose value matches the case constant
value specified in new.
Description
This procedure indicates that the storage allocated for the given dynamic
variable is no longer needed. It is an error if the argument to dispose
is NIL or undefined. After dispose, the system has closed any files in
the disposed storage and
p
is undefined.
If the case constant values are specified when calling new, it is an
error if the identical constants do not appear as the parameters in the
call to dispose. It is also an error if the pointer argument
p
references a dynamic variable to which another reference exists. This
would be the case if it is a reference parameter, part of a reference
parameter, or another pointer to it exists elsewhere.
Using dispose may be equivalent to executing an empty statement. For
more details, see the
HP Pascal/iX Programmer's Guide
or the
HP
Pascal/HP-UX Programmer's Guide
, depending on your implementation, or the
compiler options "HEAP_COMPACT" and "HEAP_DISPOSE" .
Example
PROGRAM show_dispose (output);
TYPE
marital_status = (single, engaged, married, widowed, divorced);
year = 1900..2100;
ptr = ^person_info;
person_info = RECORD
name: string[25];
birdate: year;
next_person: ptr;
CASE status: marital_status OF
married..divorced: (when: year;
CASE has_kids: boolean OF
true: (how_many:1..50);
false: ();
);
engaged: (date: year);
single : ();
END;