comp.lang.ada
 help / color / mirror / Atom feed
From: Pawel Kobylarz <kobylarz@wbkst21.mach.uni-karlsruhe.de>
Subject: Re: Unbounded array
Date: 1999/04/27
Date: 1999-04-27T00:00:00+00:00	[thread overview]
Message-ID: <37262C39.D4F16DD8@wbkst21.mach.uni-karlsruhe.de> (raw)
In-Reply-To: 7g23a9$k3k$1@nnrp1.dejanews.com

Robert Dewar wrote:

> In article
> <37247AA2.116F5E00@wbkst21.mach.uni-karlsruhe.de>,
>   kobylarz@wbkst21.mach.uni-karlsruhe.de wrote:
> > Is there in ADA a way to obtain something like unbouned
> > array?
>
> Well most certainly you can use EXACTLY the same procedure
> you use in C (lookup allocators and the NEW keyword in your
> Ada text book).
>
> But if you are using GNAT, also look up GNAT.Table (in file
> g-table.ads) which provides exactly the abstraction you are
> looking for.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own


Maybe my textbook is incomplete, maybe there was a misunderstanding
because
I gave wrong description of realloc function.

Using new and unchecked_deallocation, I can change the size of array
by allocating new array, copy the objects and deallocate the old one.
This is not efficient.

Realloc function takes two parameters, the actual pointer and new size,
and
it preserves the data already present in the memory block.
Realloc is more efficient than allocate-copy-deallocate,
because it can add a piece of memory without moving existing data
if there is place after the existing block.

In my textbook, I found only operators new and unchecked deallocation,
nothing similar to realloc(). Is there in ADA something like
realloc?

Pawel Kobylarz






  reply	other threads:[~1999-04-27  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-26  0:00 Unbounded array Pawel Kobylarz
1999-04-26  0:00 ` Robert Dewar
1999-04-27  0:00   ` Pawel Kobylarz [this message]
1999-04-28  0:00     ` Matthew Heaney
1999-04-29  0:00     ` Matthew Heaney
1999-04-29  0:00       ` dennison
1999-04-27  0:00   ` Pawel Kobylarz
replies disabled

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