comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Dynamic allocation in the predefined language environment
Date: Mon, 06 Jul 2015 11:45:06 -0700
Date: 2015-07-06T11:45:06-07:00	[thread overview]
Message-ID: <mnei8u$kpj$3@dont-email.me> (raw)
In-Reply-To: <559a623d$0$293$14726298@news.sunsite.dk>

On 07/06/2015 04:13 AM, Matthias-Christian Ott wrote:
> I need to store strings of unknown length. For security reasons I set
> limits for the types of strings the software handles and I used
> bounded-length strings to store them. However, it turned out that
> bounded-length strings do not fit the use case very well because the
> software sometimes has to convert between bounded-length strings of
> various types which makes the code verbose and hard to read and more
> importantly the limits are quite high so that I'm in trouble running out
> of stack space.
> 
> In order to avoid the limitations of bounded-length data structures I'm
> currently looking for alternatives.
> 
> Unbounded-length strings do not have this limitation but requires
> dynamic memory allocation (or at least I see no other way to implement
> it) which in turn requires error handling of memory allocation errors.
> However, if I'm not mistaken neither Ada 95, nor Ada 2005, nor Ada 2012
> specify how memory allocation errors are to be reported or handled and
> do not allow one to specify the storage pool from which unbounded-length
> strings are allocated. The same seems to be true for other
> unbounded/infinite data-structures. I suppose most implementations will
> raise a Storage_Error exception but the standard does not specify how
> the packages are to implemented so a program could simply crash and
> would still conform to the standard.

As Duff has pointed out, the language requires that Storage_Error be raised.

Unbounded_String is essentially an instantiation of Vectors with Positive as the
index type and Character as the element, with some added operations. As with all
of the standard library, they are general purpose and may not be suitable where
the S/W has specific needs. In this case, if knowing that Storage_Error will be
raised doesn't help, you may need to create a version of variable-length strings
that meets your requirements.

-- 
Jeff Carter
"It's symbolic of his struggle against reality."
Monty Python's Life of Brian
78

  parent reply	other threads:[~2015-07-06 18:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 11:13 Dynamic allocation in the predefined language environment Matthias-Christian Ott
2015-07-06 13:04 ` G.B.
2015-07-06 14:21   ` Matthias-Christian Ott
2015-07-06 14:06 ` Bob Duff
2015-07-06 14:16   ` Matthias-Christian Ott
2015-07-06 14:23     ` G.B.
2015-07-06 14:43       ` Matthias-Christian Ott
2015-07-06 14:56         ` Bob Duff
2015-07-07  8:46           ` Matthias-Christian Ott
2015-07-07 22:32             ` Bob Duff
2015-07-08 19:47               ` Randy Brukardt
2015-07-08 21:08                 ` Bob Duff
2015-07-10 21:58                   ` Randy Brukardt
2015-07-08 21:16                 ` Dmitry A. Kazakov
2015-07-06 14:45     ` Bob Duff
2015-07-06 20:28       ` Randy Brukardt
2015-07-07  8:49       ` Matthias-Christian Ott
2015-07-07 22:14         ` Bob Duff
2015-07-06 15:29   ` Simon Wright
2015-07-06 20:31     ` Randy Brukardt
2015-07-06 21:35       ` Simon Wright
2015-07-07 18:29         ` Randy Brukardt
2015-07-06 20:22   ` Randy Brukardt
2015-07-06 18:45 ` Jeffrey R. Carter [this message]
2015-07-07  7:42 ` Dmitry A. Kazakov
2015-07-07  8:23   ` Matthias-Christian Ott
2015-07-07  8:46     ` Dmitry A. Kazakov
replies disabled

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