comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Help with designing data structure for novice Ada programmer
Date: Fri, 14 Jan 2022 18:40:22 +0100	[thread overview]
Message-ID: <srsci5$s4e$1@gioia.aioe.org> (raw)
In-Reply-To: jj73ug5cv48bq7cl6h3te37e2t6n9gugt1@4ax.com

On 2022-01-14 17:05, Dennis Lee Bieber wrote:
> On Fri, 14 Jan 2022 00:01:22 -0500, "1.AAC0832" <z24ba7.net> 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

      reply	other threads:[~2022-01-14 17:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08 20:41 Help with designing data structure for novice Ada programmer Aleksy Grabowski
2022-01-09  2:36 ` Paul Rubin
2022-01-09  9:49   ` Aleksy Grabowski
2022-01-09 10:10     ` Dmitry A. Kazakov
2022-01-14  5:01   ` 1.AAC0832
2022-01-14 16:05     ` Dennis Lee Bieber
2022-01-14 17:40       ` Dmitry A. Kazakov [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox