From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,INVALID_MSGID, PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3c37d6ac44550e08 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: ??? Help!: how to do unconstraned arrays/records??? Date: 1998/11/05 Message-ID: #1/1 X-Deja-AN: 408745936 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <3641D77A.C7AB597@elca-matrix.ch> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-11-05T00:00:00+00:00 List-Id: Mats Weber (Mats.Weber@elca-matrix.ch) wrote: : Tucker Taft wrote: : > type System_Config_Typ(Number_Of_Node_Widgets : Natural; : > Number_Of_Hosts_Widgets : Natural) is : > record : > Number_of_nodes : Natural := 0; : > Nodes : Node_Array(1..Number_Of_Node_Widgets) := : > (others => new Node_Config_Typ(Number_Of_Hosts_Widgets)); : > end record; : This looks dangerous to me because declaring an object of that type will : allocate stuff from the heap, which may cause a memory leak. I would : prefer explicit allocation (i.e. no default initial value for Nodes). This won't allocate any heap objects if you specify Number_Of_Hosts_Widgets => 0 in the declaration. In any case, I would generally agree with you that types which implicitly use the heap as part of their default initialization are dangerous. Since the exercise was to create a type for heap allocation, it seemed OK to do it here. -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA An AverStar Company