comp.lang.ada
 help / color / mirror / Atom feed
* Re: Question about Finalization Control and reference counting
@ 2001-04-25 11:08 Christoph Grein
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Grein @ 2001-04-25 11:08 UTC (permalink / raw)
  To: comp.lang.ada

There is a package called Safe_Pointers in my home page. It was published some 
time ago in Ada Letters. It implements reference-counted pointers: Data is 
allocated once and deallocated only if there are not pointers left. You can use 
it as a reusable component instead of Ada's access types. It comes with full 
documentation (i.e. a copy of the Ada Letters article).

http://home.T-Omline.de/home/Christ-Usch.Grein/Ada/





^ permalink raw reply	[flat|nested] 11+ messages in thread
* Question about Finalization Control and reference counting
@ 2001-04-21 12:37 Preben Randhol
  2001-04-21 12:44 ` Preben Randhol
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Preben Randhol @ 2001-04-21 12:37 UTC (permalink / 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.�



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2001-04-26  8:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-25 11:08 Question about Finalization Control and reference counting Christoph Grein
  -- strict thread matches above, loose matches on Subject: below --
2001-04-21 12:37 Preben Randhol
2001-04-21 12:44 ` 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

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