From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5d38b71c771be34e,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-12 15:44:12 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newspeer.monmouth.com!newsfeed.mathworks.com!wn3feed!wn1feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc02.POSTED!not-for-mail From: Caffeine Junky Subject: Unchecked Deallocation? Newsgroups: comp.lang.ada User-Agent: Pan/0.11.3 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Comment-To: ALL Message-ID: <_YIX8.483917$352.79617@sccrnsc02> NNTP-Posting-Host: 12.245.48.122 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc02 1026513850 12.245.48.122 (Fri, 12 Jul 2002 22:44:10 GMT) NNTP-Posting-Date: Fri, 12 Jul 2002 22:44:10 GMT Organization: AT&T Broadband Date: Fri, 12 Jul 2002 22:44:10 GMT Xref: archiver1.google.com comp.lang.ada:27028 Date: 2002-07-12T22:44:10+00:00 List-Id: I think I'm getting a handle on using Unchecked Deallocation. However I'm running into a problem. In my spec file I have these types defined... with unchecked_deallocation; generic type Item is private; package genstack is -- A basic generic stack. Singlely linked list. -- type stack is limited private; ... -- Some other procedures defined here. -- function Clear_Stack(S : in Stack) return Boolean; private type Cell; type stack is access Cell; type Cell is record Value: Item; Next: Stack; end record; end genstack; Now in the body of the package I have this... package body genstack is procedure Free is new Unchecked_Deallocation(Cell, Stack); ..... -- Some other procedures here -- function Clear_Stack(S : in Stack) return Boolean is -- Return True or -- or False if the -- operation succeeded. -- begin Free(Stack); return True; -- No reason for it not to return True in this -- -- instance, as far as I can tell. -- end Clear_Stack; end genstack; Now, when attempting to compile the code, I get this... 41. Free(Stack) | >>> Invalid use of subtype mark in expression or call >>> actual for 'X' must be a variable I'm using Gnat 3.14p (Debian) Now, as far as I can tell, I cannot give it an actual variable because Cell is defined in the private type and is only accessible via the 'Stack' pointer variable. I dont think even Aliases can get past this rule. Also, the Unchecked_Deallocation documentation in the LRM that came with GNAT (found it using GNU Info) shows Unchecked_Deallocation being instantiated just the way I did it here.(Assuming I understood the docs.) As does my "Programming in Ada95" book by John Barnes. I suspect that it needs access to the Cell variable declared in the private section, but I'm not sure how to do that safely. Any pointers would be appreciated. St4pL3