comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nick.roberts@acm.org>
Subject: Re: Type conversions on pool-specific access types
Date: Fri, 17 Oct 2003 05:27:41 +0100
Date: 2003-10-17T05:27:41+01:00	[thread overview]
Message-ID: <bmnr3u$ov25p$1@ID-25716.news.uni-berlin.de> (raw)
In-Reply-To: bmmv0o$olqei$1@ID-25716.news.uni-berlin.de

I think I should add the following note. In the example starting with:

>    type My_Object;

if instead of:

>    type My_Object_Ptr is access My_Object;

I had put:

   type My_Object_Ptr is access My_Object'Class;

and instead of :

>    procedure Free is new
Ada.Unchecked_Deallocation(My_Object,My_Object_Ptr);

I had put:

   procedure Free is new
Ada.Unchecked_Deallocation(My_Object'Class,My_Object_Ptr);

then within:

>    procedure Finalize (List: in out My_Object_List) is
>       Obj, Tmp: My_Object_Ptr;
>    begin
>       Obj := List.First;
>       List.First := null;
>       while Obj /= null loop
>          Tmp := Obj;
>          Obj := Obj.Next;
>          Free(Tmp); -- will call member's Finalize and its pool's
Deallocate
>       end loop;
>    end Finalize;

the call to Free would within itself make a dispatching call to the
appropriate Finalize, according to the actual type of each member object.

--
Regards,
Nick





  reply	other threads:[~2003-10-17  4:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-13 10:34 Type conversions on pool-specific access types Dmitry A. Kazakov
2003-10-16  1:43 ` Nick Roberts
2003-10-16 12:13   ` Dmitry A. Kazakov
2003-10-16 20:28     ` Nick Roberts
2003-10-17  4:27       ` Nick Roberts [this message]
2003-10-18  9:59       ` 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