From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: Unchecked_Deallocation with tagged types
Date: 1996/11/23
Date: 1996-11-23T00:00:00+00:00 [thread overview]
Message-ID: <x7vk9rc210y.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: 572uhr$bqf@miso.cs.uq.edu.au
paulb@cs.uq.edu.au (Paul Burnim) writes:
> I'm using my own garbage collection routine for some dynamically
> allocated objects, e.g.
>
> type anytype;
>
> type anytype_ptr is access all anytype'Class;
>
> type anytype is tagged record
> .....
> end record;
>
> type r_integer is new anytype with record
> val : integer;
> end record;
>
> my question is, if I create an unchecked_deallocation for the type
> anytype, will it correctly deallocate an object of the type r_integer,
> or do I need to explicitly call an unchecked_deallocation for r_integer.
>
> e.g.
>
> procedure Free is new
> Unchecked_Deallocation (anytype, anytype_ptr);
>
> a : anytype_ptr
> begin
> a := new r_integer'(val => 1, ...)
> Free(a);
> end;
I asked a very similar question yesterday, which hadn't made it onto
the Net by this morning. I'd checked the Rationale, FAQ, Barnes,
Feldman .. finally check John English's book (Ada 95, the craft of
object-oriented programming, ISBN 0-13-230350-7) and there's the
answer on page [.. I went straight to it in the bookshop; now where
.. ah!] 298. My version is
package T is
type X is abstract tagged null record;
type Xp is access X'Class;
procedure Deallocate (The_Xp : in out Xp);
end T;
with Unchecked_Deallocation;
package body T is
procedure Free is new Unchecked_Deallocation (X'Class, Xp);
procedure Deallocate (The_Xp : in out Xp) renames Free;
end T;
--
Simon Wright Work Email: simon.j.wright@gecm.com
Ferranti Naval Systems Voice: +44(0)1705-701778
GEC-Marconi S3I Combat Systems Division FAX: +44(0)1705-701800
next prev parent reply other threads:[~1996-11-23 0:00 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-11-22 0:00 Unchecked_Deallocation with tagged types Paul Burnim
1996-11-23 0:00 ` Simon Wright [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-04-17 21:45 DrPi
2021-04-17 22:29 ` Rod Kay
2021-04-17 22:36 ` Rod Kay
2021-04-18 9:06 ` DrPi
2021-04-18 9:07 ` Jeffrey R. Carter
2021-04-18 8:21 ` Dmitry A. Kazakov
2021-04-18 8:46 ` Gautier write-only address
2021-04-18 9:09 ` Jeffrey R. Carter
2021-04-18 10:13 ` Dmitry A. Kazakov
2022-04-16 3:44 ` Thomas
2022-04-16 8:09 ` Dmitry A. Kazakov
2021-04-18 10:20 ` J-P. Rosen
2021-04-18 10:34 ` Dmitry A. Kazakov
2021-04-18 15:14 ` J-P. Rosen
2021-04-18 15:23 ` Gautier write-only address
2021-04-18 15:53 ` J-P. Rosen
2021-04-18 16:08 ` Gautier write-only address
2022-04-16 5:00 ` Thomas
2021-04-20 18:53 ` Randy Brukardt
2021-04-20 19:35 ` Dmitry A. Kazakov
2022-04-18 5:51 ` Thomas
2022-04-18 6:26 ` Niklas Holsti
2021-04-20 20:32 ` Jeffrey R. Carter
2021-04-20 21:10 ` Niklas Holsti
2021-04-21 8:35 ` Jeffrey R. Carter
2021-04-21 10:11 ` Dmitry A. Kazakov
2021-04-24 0:49 ` Randy Brukardt
2022-04-18 1:51 ` Thomas
2021-04-18 16:08 ` Jeffrey R. Carter
2021-04-18 9:13 ` DrPi
2021-04-18 10:01 ` Dmitry A. Kazakov
2021-04-18 10:42 ` DrPi
2021-04-18 16:48 ` Jeffrey R. Carter
2021-04-20 15:57 ` Stephen Leake
2021-04-20 17:24 ` Jeffrey R. Carter
2021-04-20 17:34 ` Vincent Marciante
2021-04-20 20:56 ` Jeffrey R. Carter
2021-04-21 10:21 ` Vincent Marciante
2021-04-21 10:28 ` Vincent Marciante
2021-04-21 12:13 ` Simon Wright
2021-04-21 13:28 ` J-P. Rosen
2021-04-22 10:21 ` Vincent Marciante
2021-04-21 13:42 ` Jeffrey R. Carter
2021-04-24 1:04 ` Randy Brukardt
2021-04-22 8:55 ` Stephen Leake
2021-04-22 11:16 ` Jeffrey R. Carter
2021-04-22 15:49 ` Vincent Marciante
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox