comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Unbounded string deallocation
Date: 1999/08/26
Date: 1999-08-26T00:00:00+00:00	[thread overview]
Message-ID: <7q38et$aba@hobbes.crc.com> (raw)
In-Reply-To: 37C46FD4.A42CC1A1@res.raytheon.com


Andy Askey <askeya@res.raytheon.com> wrote in message
news:37C46FD4.A42CC1A1@res.raytheon.com...
> I am looking into using Ada.Strings.Unbounded for dynamically creating
> temporary storage of character arrays.  When I am finished processing
> the string, I want to deallocate it.  I found a "Free" routine in the
> spec but this uses a pointer to STRING and not UNBOUNDED_STRING.
>
> From the Apex ada.strings.unbounded.1.ada =>
>
>  type Unbounded_String is private;
>  type String_Access is access all String;
>  procedure Free (X : in out String_Access);
>
> Can anyone help me out with the deallocation?  Anyone have a better idea
> for dynamically allocating and deallocating memory for a small to medium
> size byte array?
>
Not only does the LRM guarantee that unbounded strings are automatically
deallocated when they go out of scope (as Martin Carlisle has pointed out),
the implementation of Unbounded strings (at least in the GNAT compiler)
provides a good example of how to provide this kind of behavior for
any type.  The use of the Ada95 controlled type mechanism makes memory
management much more straightforward.

Section 7.6 of the LRM discusses controlled types in detail.







  parent reply	other threads:[~1999-08-26  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-25  0:00 Unbounded string deallocation Andy Askey
1999-08-25  0:00 ` Martin C. Carlisle
1999-08-26  0:00   ` Pascal Obry
1999-08-26  0:00   ` Andy Askey
     [not found]     ` <37c552fd@news1.us.ibm.net>
1999-08-26  0:00       ` Marin David Condic
1999-08-29  0:00         ` Robert Dewar
1999-08-30  0:00           ` Marin David Condic
1999-08-30  0:00             ` Robert Dewar
1999-08-26  0:00       ` Michael F. Yoder
1999-08-26  0:00     ` Martin C. Carlisle
1999-08-26  0:00     ` David C. Hoos, Sr.
1999-08-26  0:00     ` Andy Askey
1999-08-26  0:00 ` David C. Hoos, Sr. [this message]
1999-08-30  0:00 ` Andy Askey
replies disabled

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