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=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Custom Storage Pool questions Date: Wed, 15 Sep 2021 08:54:07 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <72b0f8af-8b07-4989-be3f-82d53e729aben@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="35294"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:62742 List-Id: On 2021-09-15 02:21, Jere wrote: > On Tuesday, September 14, 2021 at 2:23:15 AM UTC-4, Dmitry A. Kazakov wrote: >> On 2021-09-14 02:48, Jere wrote: >> >>> Yes, but if you look at that blog, they are allocating space for the /user/ data >>> and for the Next/Prev for controlled types and First/Last for unconstrained >>> arrays in addition to the size specified by allocate. >> I do not understand your concern. The blog discusses how to add service >> data to the objects allocated in the pool. >> > I tried to better articulate my concern in my response to egilhh if you want > to take a quick look at that and see if it clarifies better. Not really. It seems that you are under impression that Allocate must allocate more size than its Size parameter asks. The answer is no, unless *you* wanted to add something to each allocated object. >> I use such pools extensively in Simple Components. E.g. linked lists are >> implemented this way. The list links are allocated in front of list >> elements which can be of any type, unconstrained arrays included. >> > The blog I saw was old, so it is completely possible it no longer is > true that GNAT does what the blog suggests. I'll take a look at your > storage pools and see how they handle things like this. I calculate the offset at run time. I keep the list of recently allocated blocks. The first time the address is asked from an element, that is, the first time an element allocated in the pool becomes known to the pool, its address is searched through the list of blocks. The minimal difference between the block address and the element address (X'Address) is the offset. This is more portable than GNAT-specific attribute Descriptor_Size. Again, if attributes to be added, then it should be the object address as allocated. The compiler always knows the proper address because this address is passed to Free, not X'Address! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de