comp.lang.ada
 help / color / mirror / Atom feed
* Unconstrained type Unchecked_Deallocation
@ 2000-03-05  0:00 Andy Askey
  2000-03-06  0:00 ` Ted Dennison
  0 siblings, 1 reply; 13+ messages in thread
From: Andy Askey @ 2000-03-05  0:00 UTC (permalink / raw)


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?

If not, any suggestions?

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;

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;


Thanx. Andy
--
Andy Askey
ajaskey@mindspring.com




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2000-04-12  0:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-05  0:00 Unconstrained type Unchecked_Deallocation Andy Askey
2000-03-06  0:00 ` Ted Dennison
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

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