From: Ted Dennison <dennison@telepath.com>
Subject: Re: Unconstrained type Unchecked_Deallocation
Date: 2000/03/06
Date: 2000-03-06T00:00:00+00:00 [thread overview]
Message-ID: <8a0h55$qc5$1@nnrp1.deja.com> (raw)
In-Reply-To: lup5csoc69dj9ko2q7fbdduf8n0i4h09ll@4ax.com
In article <lup5csoc69dj9ko2q7fbdduf8n0i4h09ll@4ax.com>,
Andy Askey <ajaskey@mindspring.com> wrote:
> I have a byte array type that is used to generate byte-arrays
> dynamically. I want to dynamically deallocate these byte-arrays. Can
> I use the following to deallocate memory?
> package tst_pkg is
> type Byte_Atype is array (integer range <>) of character;
> type Byte_Ptype is access Byte_Atype;
>
> procedure Free(The_Array : in out Byte_Ptype);
> end tst_pkg;
>
> package body tst_pkg is
> procedure Deallocate is new Ada.Unchecked_Deallocation(
> Byte_Atype, Byte_Ptype);
>
> procedure Free(The_Array : in out Byte_Ptype) is
> begin
> Deallocate(The_Array);
> end;
> end tst_pkg;
That ought to work just fine. However, I don't see the benifit of doing
this over just naming the instantiation of Unchecked_Deallocation "Free"
in the first place. They have the same parameter profile and the same
mission.
> The real question is will the Free procedure deallocate all the bytes
> allocated with the following?
>
> my_bytes : Byte_Ptype;
> begin
> my_bytes := new Byte_Atype(1..100);
> tst_pkg.Free(my_bytes);
> end;
Of course. If not, your compiler is seriously broken!
--
T.E.D.
http://www.telepath.com/~dennison/Ted/TED.html
Sent via Deja.com http://www.deja.com/
Before you buy.
next prev parent reply other threads:[~2000-03-06 0:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-05 0:00 Unconstrained type Unchecked_Deallocation Andy Askey
2000-03-06 0:00 ` Ted Dennison [this message]
2000-03-06 0:00 ` John English
2000-03-06 0:00 ` Ted Dennison
[not found] ` <38C566CE.6283C0AD@rational.com>
2000-03-08 0:00 ` Robert Dewar
2000-03-08 0:00 ` Larry Kilgallen
2000-04-05 0:00 ` Robert I. Eachus
2000-04-06 0:00 ` P. S. Norby
2000-04-06 0:00 ` Robert Dewar
2000-04-09 0:00 ` Robert I. Eachus
2000-04-09 0:00 ` Robert Dewar
2000-04-12 0:00 ` Robert I. Eachus
2000-03-06 0:00 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox