home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / chap15 / buggy1 / buggy1.dpr next >
Encoding:
Text File  |  1995-03-21  |  904 b   |  40 lines

  1. program Buggy1;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: BUGGY1 }
  5.  
  6. { This programs demonstrates the fact that you
  7.   need to allocate memory for a pointer before
  8.   you use it. If you don't allocate the memory,
  9.   you risk generating a GPF.
  10.  
  11.   Set HeapLimit to zero when you are trying to
  12.   discover memory leaks in your programs. It
  13.   helps you track down errors by increasing the
  14.   likelihood that pointer errors will raise
  15.   exceptions at the place in your code where
  16.   the trouble begins. In other words, the error
  17.   is less likely to show up later, and more likely
  18.   to show up at exactly the place in your code
  19.   where you forgot to allocate, dispose, or dereference
  20.   memory.
  21. }
  22.  
  23. uses
  24.   WinCrt;
  25.  
  26. {$R+,S+}
  27.  
  28. type
  29.   PString = ^String;
  30.  
  31. var
  32.   MyString: PString;
  33.  
  34. begin
  35.   HeapLimit := 0; 
  36.   MyString^ := 'Hello';
  37.   WriteLn(MyString^);
  38. end.
  39.  
  40.