home *** CD-ROM | disk | FTP | other *** search
- program Pointer5;
- uses
- Strings;
-
- 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, 16); { 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 in ASM block}
- mov word ptr B, 0; { Zero out offset }
- mov word ptr B + 2, 0;{ Zero out segment }
- end; { Close ASM block }
- end. { Close program }
-