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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: A simple question about the "new" allocator Date: Tue, 12 Aug 2014 09:35:11 +0200 Organization: cbb software GmbH Message-ID: References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: yj8+JIQUMOEawvIM7K49kA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:188376 Date: 2014-08-12T09:35:11+02:00 List-Id: On Mon, 11 Aug 2014 23:54:50 -0700 (PDT), NiGHTS wrote: > With all default configurations using a typical Ada compiler, will the following code run indefinitely without fail or will it eventually crash? > > procedure main is > > Test : access Positive; > > begin > > loop > Test := new Positive; > end loop; > > end main; > > If this does crash, what would be another way to write this program so > that it does not crash? > > I would prefer not to use Ada.Unchecked_Deallocation. Write a custom memory pool that does not allocate anything. Make Test a pointer to that pool. P.S. It might sound silly, but such pools are actually useful. When the object is already allocated and you want to initialize it and get a pointer to, one way to do that is using a fake allocator. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de