comp.lang.ada
 help / color / mirror / Atom feed
From: fracttcarf@yahoo.co.kr (Bini)
Subject: Memory_Management
Date: 18 Apr 2005 18:39:39 -0700
Date: 2005-04-18T18:39:39-07:00	[thread overview]
Message-ID: <6cf157bb.0504181739.5c9e1bbb@posting.google.com> (raw)

with Ada.Finalization;
with Memory_Management;

package Pkg is
	My_Pool : Memory_Management.User_Pool(Size => 500);

	type My_Int is access Integer;
	for My_Int'Storage_Pool use My_Pool;

	type My_Data is new Ada.Finalization.Controlled with record
		Value	: My_Int;
	end record;

	procedure Initialize(Data : in out My_Data);
	procedure Finalize(Data : in out My_Data);
end Pkg;

with Ada.Unchecked_Deallocation;

package body Pkg is
	.
        .
	procedure Finalize(Data : in out My_Data) is
	begin
		Free(Data.Value);
	end Finalize;
        .
        .
end Pkg;

with Ada.Text_IO;
with Ada.Finalization;
with Pkg;
procedure Fun is
	package TIO renames Ada.Text_IO;
	package AF renames Ada.Finalization;

	I1, I2	: Pkg.My_Data;
	I3	: Pkg.My_Int;
begin
	I1 := (AF.Controlled with Value => new Integer'(123));
	TIO.Put_Line(I1.Value.all'Img);
	I2 := (AF.Controlled with Value => new Integer'(456));
	TIO.Put_Line(I2.Value.all'Img);
	I3 := new Integer'(789);
	TIO.Put_Line(I3.all'Img);
end Fun;


===> I write some test code with Memory_Management
package(http://www.adapower.com/index.php?Command=Class&ClassID=Advanced&CID=222)
from Anh Vo

fun.exe result is

0
0
789

and I1.Value'Address and I2.Value'Address is equal.
I can not understand this result.
My English is poor.
Thank You.



             reply	other threads:[~2005-04-19  1:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-19  1:39 Bini [this message]
2005-04-19  9:18 ` Memory_Management Duncan Sands
2005-04-20  1:06   ` Memory_Management Bini
  -- strict thread matches above, loose matches on Subject: below --
2005-04-19 20:30 Memory_Management Anh Vo
2005-05-26  0:57 memory management alex goldman
2005-05-26  2:14 ` David C. Hoos, Sr.
2005-05-26 13:21   ` Steve
2005-05-26 18:40     ` alex goldman
2005-05-28  2:13       ` Steve
2005-05-28  5:19         ` Jeffrey Carter
2005-05-28 14:48           ` Steve
2005-05-26 18:47     ` Pascal Obry
2005-05-27 14:33   ` Martin Krischik
2005-05-26 12:10 ` Robert A Duff
2005-05-27 14:31   ` Martin Krischik
2005-05-28 11:44     ` Robert A Duff
2005-05-28 13:03       ` Simon Wright
2005-05-31 12:04         ` Robert A Duff
2005-06-02 15:42       ` Thomas Maier-Komor
2005-06-02 17:05         ` Robert A Duff
2005-06-03  1:41       ` Steve
2005-06-03 10:12         ` alex goldman
2005-06-13  4:01         ` Dave Thompson
replies disabled

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