From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.0 required=3.0 tests=BAYES_20,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:620a:81c:: with SMTP id s28mr2389005qks.45.1631580495722; Mon, 13 Sep 2021 17:48:15 -0700 (PDT) X-Received: by 2002:a25:3086:: with SMTP id w128mr18904648ybw.139.1631580495526; Mon, 13 Sep 2021 17:48:15 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 13 Sep 2021 17:48:15 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 98.118.241.166 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Custom Storage Pool questions From: Jere Injection-Date: Tue, 14 Sep 2021 00:48:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:62727 List-Id: On Monday, September 13, 2021 at 7:12:43 AM UTC-4, J-P. Rosen wrote: > Le 13/09/2021 =C3=A0 02:53, Jere a =C3=A9crit :=20 > > I was learning about making user defined storage pools when=20 > > I came across an article that made me pause and wonder how=20 > > portable storage pools actually can be. In particular, I assumed=20 > > that the Size_In_Storage_Elements parameter in the Allocate=20 > > operation actually indicated the total number of storage elements=20 > > needed.=20 > >=20 > > procedure Allocate(=20 > > Pool : in out Root_Storage_Pool;=20 > > Storage_Address : out Address;=20 > > Size_In_Storage_Elements : in Storage_Elements.Storage_Count;=20 > > Alignment : in Storage_Elements.Storage_Count) is abstract;=20 > >=20 > > But after reading the following AdaCore article, my assumption is now= =20 > > called into question:=20 > > https://blog.adacore.com/header-storage-pools=20 > >=20 > > In particular, the blog there advocates for separately counting for=20 > > things like unconstrained array First/Last indices or the Prev/Next=20 > > pointers used for Controlled objects. Normally I would have assumed=20 > > that the Size_In_Storage_Elements parameter in Allocate would account= =20 > > for that, but the blog clearly shows that it doesn't > [...]=20 >=20 > That blog shows a special use for Storage_Pools, where you allocate=20 > /user/ data on top of the requested memory. When called by the compiler,= =20 > it is up to the compiler to compute how much memory is needed, and your= =20 > duty is to just allocate that.=20 >=20 Yes, but if you look at that blog, they are allocating space for the /user/= data=20 and for the Next/Prev for controlled types and First/Last for unconstrained arrays in addition to the size specified by allocate. =20 I agree I feel it is up to the compiler to provide the correct size to Allo= cate,=20 but the blog would indicate that GNAT does not (or did not..old blog..so=20 who knows?). Does the RM require that an implementation pass the full amount of memory needed to Allocate when new is called? =20