comp.lang.ada
 help / color / mirror / Atom feed
From: "Grein, Christoph" <christoph.grein@eurocopter.com>
To: comp.lang.ada@ada.eu.org
Subject: Re: Pitfall: freeing access discriminants
Date: Fri, 14 Feb 2003 07:02:09 +0100 (MET)
Date: 2003-02-14T07:02:09+01:00	[thread overview]
Message-ID: <mailman.12.1045202989.13246.comp.lang.ada@ada.eu.org> (raw)

>   In this case, you can shoot safely away from your foot with
> Christoph Grein's suggested:
> > procedure Finalize (Object: in out T) is
> >   type Integer_Ptr is access all Integer;
> >   procedure Free is new Ada.Unchecked_Deallocation (Integer, Integer_Ptr);
> >   P: Integer_Ptr := Integer_Ptr (Object.D);
> > begin
> >   Free (P);
> > end Finalize;
> 
> I seems to me that you needn't worry that
> > Because of storage pools for Integer_Ptr may be different
> > from storage pool used by "new".
> because you get a standard storage pool unless you specify otherwise, so
> > type T(D: access Integer)
> >   type Integer_Ptr is access all Integer;
> should both refer to the same storage pool.

Hm, I wouldn't be so sure... Better to consult the implementor's manuals. There is nothing in the RM that prevents an implementation from selecting different 
"standard" storage pools for objects allocated for access types and those 
allocated for access discriminants.

Gnat for instance uses different pools depending on the kind of allocation, so 
cannot be sure that access types without a named pool use the same pool.



             reply	other threads:[~2003-02-14  6:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-14  6:02 Grein, Christoph [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-02-14  6:21 Pitfall: freeing access discriminants Grein, Christoph
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-13 10:04 Victor Porton
2003-02-13 12:07 ` Victor Porton
2003-02-13 13:42   ` Preben Randhol
2003-02-13 17:40 ` Stephen Leake
2003-02-13 19:24   ` Victor Porton
replies disabled

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