From: Randy Kosarik <randyk@access.hky.com>
Subject: "free"ing allocated memory
Date: 1997/11/12
Date: 1997-11-12T00:00:00+00:00 [thread overview]
Message-ID: <34693B2D.C53FFFC3@access.hky.com> (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;
next reply other threads:[~1997-11-12 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-11-12 0:00 Randy Kosarik [this message]
1997-11-16 0:00 ` "free"ing allocated memory Jerry van Dijk
1997-12-16 0:00 ` Pascal MALAISE
1997-11-18 0:00 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox