From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,edd7ea1b2d7e9a18 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-13 22:09:51 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!teaser.fr!enst.fr!not-for-mail From: "Grein, Christoph" Newsgroups: comp.lang.ada Subject: Re: Pitfall: freeing access discriminants Date: Fri, 14 Feb 2003 07:02:09 +0100 (MET) Organization: ENST, France Message-ID: Reply-To: "Grein, Christoph" , "comp.lang.ada mail to news gateway" NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-Trace: avanie.enst.fr 1045202990 84837 137.194.161.2 (14 Feb 2003 06:09:50 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 14 Feb 2003 06:09:50 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: X-Authentication-Warning: mail.eurocopter.com: uucp set sender to using -f Content-MD5: aOKbqVurQiLcD/ehq8WswQ== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:34087 Date: 2003-02-14T07:02:09+01:00 > 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.