From: Stephen Leake <Stephen.A.Leake@nasa.gov>
Subject: Re: Pitfall: freeing access discriminants
Date: 13 Feb 2003 12:40:36 -0500
Date: 2003-02-13T17:53:39+00:00 [thread overview]
Message-ID: <uptpwoz8r.fsf@nasa.gov> (raw)
In-Reply-To: E18jGE0-0003dI-00@porton.narod.ru
porton@ex-code.com (Victor Porton) writes:
> type Integer_Access is access Integer;
>
> type T(D: access Integer) is Ada.Limited_Controlled with null record;
>
> procedure Finalize(Object: in out T) is
> -- Error: cannot convert access discriminant to non-local access type
> D: Integer_Access := Integer_Access(Object.D);
> begin
> Free(D);
> end;
>
> What to do? It seems being a serious deficiency in Ada or there are a
> workaround?
Why would you ever want to free an access discriminant? I usually use
them to point to a constant object.
One good rule for dynamic memory allocation; never free something you
did not allocate.
--
-- Stephe
next prev parent reply other threads:[~2003-02-13 17:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-13 10:04 Pitfall: freeing access discriminants Victor Porton
2003-02-13 12:07 ` Victor Porton
2003-02-13 13:42 ` Preben Randhol
2003-02-13 17:40 ` Stephen Leake [this message]
2003-02-13 19:24 ` Victor Porton
-- strict thread matches above, loose matches on Subject: below --
2003-02-13 12:41 Grein, Christoph
2003-02-13 13:38 ` Victor Porton
2003-02-13 20:49 ` tmoran
2003-02-13 21:17 ` Simon Wright
2003-02-14 4:16 ` tmoran
2003-02-14 21:30 ` Simon Wright
2003-02-14 8:28 ` Victor Porton
2003-02-22 19:00 ` Robert A Duff
2003-02-14 6:02 Grein, Christoph
2003-02-14 6:21 Grein, Christoph
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox