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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3839fc233928a180,start X-Google-Attributes: gid103376,public From: Randy Kosarik Subject: "free"ing allocated memory Date: 1997/11/12 Message-ID: <34693B2D.C53FFFC3@access.hky.com>#1/1 X-Deja-AN: 289586673 Organization: The Access Hickory Internet Network Newsgroups: comp.lang.ada Date: 1997-11-12T00:00:00+00:00 List-Id: (This is the 4th time I am trying to send this to the newsgroup so, please disregard any copies if they make it here.... ISP has a newsserver problem) Hi, I have a project in school that is completed with the exception of one part. Releasing the memory that I am no longer using in my linked lists. While the program would never use all of the memory in the machine, I do not like the idea of making my code any sloppier than I already do (experience should remove my wasteful code ). I have included two snippetts of my code and am currently using GNAT 3.10p/Win95 for the creation. I will have to recompile on GNAT2.07 for DOS to demonstrate the program since my professor does not have Win95/NT compatability. Thanks in advance, -Randy ----------------------------------- The structure and pointers are declared as such... with Gnat.Io, Text_Io; use Gnat.Io; procedure Register is subtype Name_String is String (1..15); subtype Ssn_String is String (1..11); type Student_Struct is record First_Name : Name_String; Last_Name : Name_String; Ssn : Ssn_String; end record; type Link; type P is access Link; type Link is record Line : Student_Struct; Next : P; end record; ---------------------------------------------- I allocate/create the new memory blocks with this routine.. But I cannot seem to figure out how to "free" the memory in Ada. function New_Node(Junk : Integer) return P is --this function creates a memory location and returns the address Node : P := new Link; --create new memory location begin Node.Next := null; --make it point to NULL return (Node); --return address of pointer end New_Node;