comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Exception_Access_Violation
Date: Fri, 22 May 2009 18:17:26 +0300
Date: 2009-05-22T18:17:26+03:00	[thread overview]
Message-ID: <4a16c1e3$0$6285$4f793bc4@news.tdc.fi> (raw)
In-Reply-To: <77nrfgF1iajvfU1@mid.individual.net>

Bj�rn Persson wrote:
> mhamel_98@yahoo.com wrote:
> 
> 
>>Problem solved!  Thanks for all the help, especially the pointer to
>>Debug_Pools.  The problem was that instead of allocating one node at a
>>time, I was allocating an array of nodes at once.  Deallocating nodes
>>allocated from an array allocation is apparently bad juju.  I don't
>>understand it, but can work around it.
> 
> 
> When you have allocated an array you must also deallocate it as an array.
> You can't deallocate individual elements of an array.

Just to add to Bj�rn's comment: If you have an indexed collection 
of nodes, and want to deallocate nodes at some indices without 
deallocating them all at once, you can make an array of access values.

For example:

    type Node is ...
    type Node_Ref is access Node;
    procedure Deallocate is new Unchecked_Deallocation (...)

    Collection : array (1 .. 100) of Node_Ref:

Now you can do:

    Collection(5) := new Node;

Collection(5) now contains an access to a new Node. Later you can do:

    Deallocate (Collection(5));

The new node is now deallocated and Collection(5) is null.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  reply	other threads:[~2009-05-22 15:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-18 16:05 Exception_Access_Violation mhamel_98
2009-05-18 16:14 ` Exception_Access_Violation John B. Matthews
2009-05-19  7:23   ` Exception_Access_Violation Alex R. Mosteo
2009-05-20 15:30     ` Exception_Access_Violation mhamel_98
2009-05-22 14:34       ` Exception_Access_Violation Björn Persson
2009-05-22 15:17         ` Niklas Holsti [this message]
2009-05-22 16:38       ` Exception_Access_Violation Adam Beneschan
  -- strict thread matches above, loose matches on Subject: below --
2006-11-13 19:31 exception access violation Jade
2006-11-13 21:35 ` Georg Bauhaus
2006-11-14  9:09 ` Alex R. Mosteo
2006-11-14 19:34   ` Jade
2006-11-15  9:58     ` Alex R. Mosteo
2006-11-15  9:52       ` Georg Bauhaus
2006-11-15 13:32         ` Alex R. Mosteo
2006-11-15 23:43         ` Kevin K
2001-12-07 12:41 Cousins, Jeff
replies disabled

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