home *** CD-ROM | disk | FTP | other *** search
- -- ++
- -- Simple program to test Unchecked_Deallocation and see whether the
- -- implementation actually free's storage allocated with new.
- -- --
-
- with Text_IO;
- with Unchecked_Deallocation;
- procedure Dealloc is
-
- type Cell;
- type Link is access Cell;
-
- type Cell is record
- Value : Integer;
- Next : Link;
- end record;
-
- List : Link;
-
- procedure Free is new Unchecked_Deallocation ( Cell, Link );
-
- begin
- for I in Positive loop
- List := new Cell'(I, null);
- if I mod 100 = 0 then
- Text_IO.Put_Line ( Positive'Image(I) );
- end if;
- Free ( List ); -- doesn't free under this implementation
- end loop;
- end Dealloc;