comp.lang.ada
 help / color / mirror / Atom feed
* Ada 2005,Doubly_Linked_List with Controlled parameter
@ 2016-04-05  2:03 George J
  2016-04-05  2:27 ` Jeffrey R. Carter
  0 siblings, 1 reply; 19+ messages in thread
From: George J @ 2016-04-05  2:03 UTC (permalink / raw)


Hi all! I'm using Doubly_Linked_List with Controlled param, example here:

   ----------------------------------------------------------------------
   type Info_Record is new Controlled with
      record
         Name:String_Access;
      end record;
   type Info is access all Info_Record'Class;
   overriding procedure Finalize(Self:in out Info_Record);

   package Test_Containers is new Ada.Containers.Doubly_Linked_Lists(Info_Record);
   use Test_Containers;

   Test_List:Test_Containers.List;
   ----------------------------------------------------------------------
   procedure Free_String is new Ada.Unchecked_Deallocation
(Object => String,
 Name   => String_Access);

   overriding procedure Finalize(Self:in out Info_Record) is
   begin
      if  Self.Name/=null then
            Free_String(Self.Name);
      end if;
   end Finalize;

   ----------------------------------------------------------------------
   procedure Test is
   begin
   Test_List.Append(Info_Record'(Controlled with
                                   Name => new String'("Test_Name"));
   end Test;
   ----------------------------------------------------------------------

  Problem is that after calling "Append"->at once starts Finalization proc, so appended pure line. I just use an access parameter after this "Doubly_Linked_List(Info)", and it's ok now,but i think that i'm wrong,cause Finalization doesn't start with Test_List.Clear and when exiting program. So question is "How I can finalize Doubly_Connected_List Controlled parameter correctly?Or I must not use Controlled parameter in this list?".
Thanks!

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

end of thread, other threads:[~2016-04-07  1:28 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-05  2:03 Ada 2005,Doubly_Linked_List with Controlled parameter George J
2016-04-05  2:27 ` Jeffrey R. Carter
2016-04-05  3:00   ` George J
2016-04-05  4:13     ` George J
2016-04-05  6:20     ` Jeffrey R. Carter
2016-04-05  6:31       ` George J
2016-04-05  7:58     ` Dmitry A. Kazakov
2016-04-05  8:09       ` George J
2016-04-05  8:35       ` George J
2016-04-05  8:50         ` Dmitry A. Kazakov
2016-04-05  8:57           ` George J
2016-04-05 16:22         ` Jeffrey R. Carter
2016-04-06  1:14           ` George J
2016-04-05  3:25   ` George J
2016-04-05  5:24     ` Jeffrey R. Carter
2016-04-05  6:30       ` George J
2016-04-06 20:29         ` Randy Brukardt
2016-04-06 21:04           ` Jeffrey R. Carter
2016-04-07  1:28           ` George J

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