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!yWEAdf48JK7zWb9n7RvSRA.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Help with designing data structure for novice Ada programmer Date: Fri, 14 Jan 2022 18:40:22 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <87sftx1vpd.fsf@nightsong.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="28814"; posting-host="yWEAdf48JK7zWb9n7RvSRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63373 List-Id: On 2022-01-14 17:05, Dennis Lee Bieber wrote: > On Fri, 14 Jan 2022 00:01:22 -0500, "1.AAC0832" declaimed the > following: > > >> You DO have to bring in a special proc to FREE memory allocated >> on the heap however. Kinda weird - you'd think making and freeing >> would naturally be implemented together. This "free()" is very >> type-specific, multiple incarnation of the proc will be needed >> if you have multiple kinds of records to free. >> > Take into account the origins for Ada. Many embedded/real-time > applications follow the practice of pre-allocating all memory during > application initialization before transitioning into "running" mode. They > never deallocate memory. If something goes wrong, the entire application > system is rebooted, resetting all memory. They may use some special management of resources that do not involve heap and explicit deallocation. E.g. a linked list can be allocated in an arena. There would be no free(), the whole list gets killed when the arena is erased. The arena itself may sit in a local/static storage array or a pre-allocated upon start array. Ada provides user memory pools for that kind of implementations. As an example consider a network protocol implementation. There would be a fixed-size storage per connection where entities of an incoming packet are stored upon parsing it. After processing the packet the storage is emptied. No buffer overflow or network attacks possible. If the packet has too much data, Storage_Error is propagated from new and the connection gets dropped. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de