From: Jeffrey Carter <spam@spam.com>
Subject: Re: Unchecked deallocation question
Date: Wed, 24 Nov 2004 17:24:01 GMT
Date: 2004-11-24T17:24:01+00:00 [thread overview]
Message-ID: <Rs3pd.2908$NU3.1741@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <41A4AAFF.5060407@mailinator.com>
Alex R. Mosteo wrote:
> type Root is tagged record ...
>
> type Root_Access is access Root;
>
> type Derived is new Root with ...
>
> type Derived_Access is access Derived;
>
> procedure Free is
> new Ada.Unchecked_Deallocation (Root'Class, Root_Access);
Root_Access designates Root, not Root'Class.
>
> declare
> It : Derived_Access := new Derived;
> begin
> Free (Root_Access (It)); -- <-- THIS DEALLOCATION I'M ASKING
> end;
>
> The purpose is to have a single deallocator in the root package and to
> not have to instantiate a lot of deallocators for derived types.
You'd be better off having
type Root_Access is access Root'Class;
procedure Free is new ...
...
It : Root_Access := new Derived;
...
Free (It);
But you'd really be better off not using access types, or encapsulating
and hiding their use if that's not possible.
--
Jeff Carter
"My name is Jim, but most people call me ... Jim."
Blazing Saddles
39
next prev parent reply other threads:[~2004-11-24 17:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-24 15:38 Unchecked deallocation question Alex R. Mosteo
2004-11-24 17:24 ` Jeffrey Carter [this message]
2004-11-24 17:35 ` Alex R. Mosteo
2004-11-24 17:33 ` David Botton
2004-11-25 8:35 ` Martin Krischik
2004-11-25 9:12 ` Alex R. Mosteo
2004-11-25 23:24 ` Adrien Plisson
2004-11-26 4:05 ` Jim Rogers
2004-11-26 10:53 ` Sergey
2004-11-26 9:06 ` Dmitry A. Kazakov
2004-11-26 18:20 ` Sergey
2004-11-27 8:43 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox