comp.lang.ada
 help / color / mirror / Atom feed
From: randhol+abuse@pvv.org (Preben Randhol)
Subject: Question about Finalization Control and reference counting
Date: Sat, 21 Apr 2001 12:37:26 +0000 (UTC)
Date: 2001-04-21T12:37:26+00:00	[thread overview]
Message-ID: <slrn9e2vqb.aah.randhol+abuse@kiuk0156.chembio.ntnu.no> (raw)


Hi

I'm wondering if it is possible to do something like this

   type Data_Type is new Ada.Finalization.Controlled with
      record
         References: Integer := 0;
   end record;
   
   type Data_Access_Type is access Data_Type;

[..]

and then in the main program if I do something like this:

   procedure main is

      Pointer : Data_Access_Type := null;
      Data : Data_Access_Type := new Data_Type;
   
   begin
   
      Pointer := Data; 

   end main;

to have Data.References increases by using Adjust? I'm trying but it
looks like it only works if I do:

   Pointer : Data_Type;
   ...
   Pointer := Data.all;
   ...
otherwise Adjust is not invoked. Is it possible to get it invoked if one
point an access type to an object? I'm trying to eliminate the problem
of dangling pointers in a program...

Thanks in advance.

-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 �For me, Ada95 puts back the joy in programming.�



             reply	other threads:[~2001-04-21 12:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-21 12:37 Preben Randhol [this message]
2001-04-21 12:44 ` Question about Finalization Control and reference counting Preben Randhol
2001-04-24 16:11   ` Jeffrey Carter
2001-04-25 15:58     ` Preben Randhol
2001-04-25 16:01       ` Preben Randhol
2001-04-25 22:22       ` Jeffrey Carter
2001-04-26  8:50         ` Preben Randhol
2001-04-25 16:57     ` Stanley R. Allen
2001-04-24 16:10 ` Alexander Boucke
2001-04-25  3:14 ` DuckE
  -- strict thread matches above, loose matches on Subject: below --
2001-04-25 11:08 Christoph Grein
replies disabled

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