home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programming Unleashed
/
Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso
/
chap16
/
pointer5
/
pointer5.dpr
< prev
next >
Wrap
Text File
|
1995-03-20
|
1KB
|
31 lines
program Pointer5;
{ Program copyright (c) 1995 by Charles Calvert }
{ Project Name: POINTER5 }
uses
SysUtils;
var
A: Pointer;
B: PChar;
begin { Open program }
HeapLimit := 0; { "Turn off" Pascal sub-allocator}
A := Ptr(DSeg, 0); { A "fake" pointer to nothing, }
B := Ptr($45FF, $10); { There is no memory allocation! }
A := nil; { Set pointer to nil }
B := nil; { Set pointer to nil }
New(A); { Pointer will STILL equals nil! }
Dispose(A); { Does nothing }
GetMem(A, 100); { Allocate a hundred bytes }
GetMem(B, 100); { Allocate a hundred bytes }
StrCopy(B, 'Test data');{ Use the allocation }
FreeMem(A, 100); { Deallocate 100 bytes }
A := nil; { Set pointer to nil }
FreeMem(B, 100); { Deallocate 100 bytes }
asm { Set pointer to nil (B := nil;) }
mov word ptr B, 0; { Zero out offset }
mov word ptr B + 2, 0;{ Zero out segment }
end; { Close ASM block }
end. { Close program }