home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_03 / 1n03008b < prev    next >
Text File  |  1990-06-14  |  536b  |  40 lines

  1. ----------
  2.  
  3. Listing 2
  4.  
  5. var
  6.         p1, p2, p3, p4 : ^longint;
  7. begin
  8. {*
  9.  * Grab three chunks from the heap.
  10.  *}
  11. new(p1);
  12. p1^ := 1;
  13. new(p2);
  14. p2^ := 2;
  15. new(p3);
  16. p3^ := 3;
  17. {*
  18.  * Return the second chunk to the heap and grab
  19.  * another.
  20.  *}
  21. dispose(p2);
  22. new(p4);
  23. p4^ := 4;
  24. {*
  25.  * Whoops!  I forgot that I disposed of the second
  26.  * chunk.
  27.  *}
  28. p2^ := -2;
  29. {*
  30.  * Now look at the results...
  31.  *}
  32. writeln('p1^ = ', p1^);
  33. writeln('p2^ = ', p2^);
  34. writeln('p3^ = ', p3^);
  35. writeln('p4^ = ', p4^);
  36. end.
  37.  
  38. ----------
  39.  
  40.