comp.lang.ada
 help / color / mirror / Atom feed
* "free"ing allocated memory
@ 1997-11-12  0:00 Randy Kosarik
  1997-11-16  0:00 ` Jerry van Dijk
  1997-11-18  0:00 ` Stephen Leake
  0 siblings, 2 replies; 4+ messages in thread
From: Randy Kosarik @ 1997-11-12  0:00 UTC (permalink / raw)



(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 <HOPEFULLY!>).

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;






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-12-16  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-12  0:00 "free"ing allocated memory Randy Kosarik
1997-11-16  0:00 ` Jerry van Dijk
1997-12-16  0:00   ` Pascal MALAISE
1997-11-18  0:00 ` Stephen Leake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox