comp.lang.ada
 help / color / mirror / Atom feed
From: wdl39!mab@ford-wdl1.arpa  (Mark A Biggar)
Subject: Re: Deallocating linked lists of linked lists
Date: 20 Apr 93 16:59:30 GMT	[thread overview]
Message-ID: <1993Apr20.165930.3130@wdl.loral.com> (raw)

In article <1993Apr20.044555.154198@zeus.calpoly.edu> jplee@cymbal.calpoly.edu 
(JASON LEE) writes:
>I wrote a program that simulates a graph, and thus I need to have a linked
>list, one of whose components is a linked list, showing on which vertices
>that particular vertex is incident upon.
>Well, enough of the nitty gritty.  Here is the question.  If I have a
>variable that is a record, and one of the fields of the record is the head
>pointer to another linked list, will it be sufficient to just deallocate the
>one variable, or do I have to go inside and deallocate everthing?  Here are
>my type declarations:
> type pointer is access edge;
> type edge is record
>  incident_on : pointer;
>  id_number   : positive;
> end record;
> type incidence_node;
> type edge_list is access incidence_node;
> type incidence_node is record
>  item : edge;
>  next : edge_list;
> end record;
> type vertex is record
>  data      : node_item_type;
>  id_number : positive;
>  incidence : incidence_list;
> end record;
> type graph is access vertex;
>So how would I dynamically deallocate something of type graph?

If your system supports garbage collection, then just deallocating
the top record should be sufficient.  If it doesn't, then you will
have to recursivly deallocate everything from the bottom up.  The only
portable way is the latter, because most Ada systems do not support
garbage collection.  Without CG, you need one call to unchecked_deallocation
for each new allocator.

--
Mark Biggar
mab@wdl1.wdl.lorla.com

             reply	other threads:[~1993-04-20 16:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-04-20 16:59 Mark A Biggar [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-04-22 19:03 Deallocating linked lists of linked lists cis.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!msuinfo!netnews.upenn.e
1993-04-20  4:45 cis.ohio-state.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!uw
replies disabled

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