home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / ada_1 / Examples_ada_dealloc < prev    next >
Encoding:
Text File  |  1994-08-14  |  640 b   |  30 lines

  1. -- ++
  2. -- Simple program to test Unchecked_Deallocation and see whether the
  3. -- implementation actually free's storage allocated with new.
  4. -- --
  5.  
  6. with Text_IO;
  7. with Unchecked_Deallocation;
  8. procedure Dealloc is
  9.  
  10. type Cell;
  11. type Link is access Cell;
  12.  
  13. type Cell is record
  14.    Value : Integer;
  15.    Next : Link;
  16. end record;
  17.  
  18. List : Link;
  19.  
  20. procedure Free is new Unchecked_Deallocation ( Cell, Link );
  21.  
  22. begin
  23.    for I in Positive loop
  24.       List := new Cell'(I, null);
  25.       if I mod 100 = 0 then
  26.          Text_IO.Put_Line ( Positive'Image(I) );
  27.       end if;
  28.       Free ( List );    -- doesn't free under this implementation
  29.    end loop;
  30. end Dealloc;