HP Pascal/iX Reference Manual (31502-90022)

12- 29
procedure
dispose
is called.
Syntax
$HEAP_COMPACT {ON }$
{OFF}
Default OFF.
Location At front.
The HEAP_COMPACT option is recommended for programs that manipulate many
dynamic record variables of different sizes via calls to the predefined
procedures
new
and
dispose
. It allows free space to be merged and
reused.
Example
$HEAP_COMPACT ON; HEAP_DISPOSE ON$
PROGRAM show_compact;
TYPE
big_rec = RECORD
f1 : ARRAY [1..4] OF integer;
END;
small_rec = PACKED RECORD
f1 : integer;
f2 : integer;
END;
VAR
p1,p2 : ^mall_rec;
p3 : ^big_rec;
BEGIN
new(p1);
new(p2);
dispose(p1);
dispose(p2);
new(p3); {p3 is allocated in the space previously
occupied by p1 and p2}
END.
HEAP_DISPOSE
HEAP_DISPOSE is an HP Pascal Option.
When the HEAP_DISPOSE compiler option is ON, the predefined procedure
dispose
frees space in the heap so that the predefined procedure
new
can
reallocate it. By default, such disposed space cannot be reused.
Syntax
$HEAP_DISPOSE {ON }$
{OFF}
Default OFF
Location At front.
Example
$HEAP DISPOSE ON$
PROGRAM show_heap;
TYPE
big_array = ARRAY [1..1000] OF longreal;
VAR
ptr : ^big_array;
i : integer;