home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_01_03
/
1n03010b
< prev
next >
Wrap
Text File
|
1990-06-14
|
750b
|
43 lines
Listing 5
procedure not_NIL(p : pointer);
function hexstr(w : word) : string;
function ptrstr(p : pointer) : string;
{*
* A safer dispose
*}
procedure dispose(var p : pointer);
begin
system.dispose(p);
p := NIL;
end;
var
p1, p2, p3, p4 : ^longint;
begin
new(p1);
{$ifdef DEBUG} not_NIL(p1); {$endif}
p1^ := 1;
new(p2);
{$ifdef DEBUG} not_NIL(p2); {$endif}
p2^ := 2;
new(p3);
{$ifdef DEBUG} not_NIL(p3); {$endif}
p3^ := 3;
dispose(pointer(p2));
new(p4);
{$ifdef DEBUG} not_NIL(p4); {$endif}
p4^ := 4;
{$ifdef DEBUG} not_NIL(p2); {$endif}
p2^ := -2;
writeln('p1^ = ', p1^);
writeln('p2^ = ', p2^);
writeln('p3^ = ', p3^);
writeln('p4^ = ', p4^);
end.
----------