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,5072448cfe6241eb,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-13 20:09:44 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn1feed!wn4feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc01.POSTED!not-for-mail From: Caffeine Junky Subject: How does this look? 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: NNTP-Posting-Host: 12.245.48.122 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc01 1026616181 12.245.48.122 (Sun, 14 Jul 2002 03:09:41 GMT) NNTP-Posting-Date: Sun, 14 Jul 2002 03:09:41 GMT Organization: AT&T Broadband Date: Sun, 14 Jul 2002 03:09:41 GMT Xref: archiver1.google.com comp.lang.ada:27077 Date: 2002-07-14T03:09:41+00:00 List-Id: I did a little simplifying of my genstack package.(Generic Stack) I got rid of Unchecked_Deallocation(although it will be going back in as I tune the package a little better.) There shouldn't be any memory leaks this time. generic Max : Positive; type Item is private; package safer_genstack is type Stack is limited private; procedure Push(X : in Item; S : in out Stack); procedure Pop(S : in out Stack; X : out Item); private type Cell; type Stack is access Cell; type Cell is record Value : Item; Next : Stack; end record; for Stack'Storage_Size use Cell'Max_Size_In_Storage_Elements * Max; end safer_genstack; With this one, notice, I didnt have to fool around with Unchecked_Deallocation. Nor is there a need for an explicit Allocator or an 'Is_Empty' function to see if anythings still there. That 'Max' variable comes in handy. package body safer_genstack is procedure Push(X : in Item; S : in out Stack) is begin S := new Cell'(X, S); end Push; procedure Pop( S : in out Stack; X : out Item) is Local : Item; begin Local := S.Value; S := S.Next; X := Local; end Pop; end safer_genstack; I do believe I'm starting to get the hang of it. Now I'll have to start doing extra checks to make sure the program isn't trying to access memory that isn't there anymore. Aaah, the joys. Anyone care to critique a novice. I'm all ears. St4pL3