comp.lang.ada
 help / color / mirror / Atom feed
From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: Elegant 'realloc'?
Date: Thu, 31 Jul 2003 14:59:01 +0000 (UTC)
Date: 2003-07-31T14:59:01+00:00	[thread overview]
Message-ID: <slrnbiibl2.2j7.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: 1ec946d1.0307310642.74d93921@posting.google.com

* Matthew Heaney wrote:
> Lutz Donnerhacke <lutz@iks-jena.de> wrote in message news:<slrnbihq0e.2j7.lutz@taranis.iks-jena.de>...
>> When dealing with dynamically allocated variable length arrays, the
>> allocated space might change. Is there a common idiom to simulate an
>> 'realloc' (especially shrinking) other than, allocate, copy, free?
>
> I don't know how to implement a realloc in Ada, unless you write your own
> storage pool.

Any hint?

> You can try using the vector container in Charles, which hides all the
> allocate, copy, and free calls.

Performance does matter in this case. So hiding necessary parts does not help.

> The length of the vector refers to the number of active elements in the
> vector.  The size of the vector refers to the length of the underlying
> array, which is at least the number of elements.

Exactly this is the way I implement it: Trading allocated space for running
time.




  reply	other threads:[~2003-07-31 14:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-31  9:57 Elegant 'realloc'? Lutz Donnerhacke
2003-07-31 14:42 ` Matthew Heaney
2003-07-31 14:59   ` Lutz Donnerhacke [this message]
2003-07-31 16:50     ` Matthew Heaney
2003-07-31 16:35 ` Nick Roberts
2003-08-01  0:01 ` Robert I. Eachus
replies disabled

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