comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: ??? Help!: how to do unconstraned arrays/records???
Date: 1998/11/05
Date: 1998-11-05T00:00:00+00:00	[thread overview]
Message-ID: <F1yoq0.Aqp.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 3641D77A.C7AB597@elca-matrix.ch

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




  reply	other threads:[~1998-11-05  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-04  0:00 ??? Help!: how to do unconstraned arrays/records??? al johnston
1998-11-04  0:00 ` Albert S. Johnston
1998-11-05  0:00   ` dewarr
1998-11-05  0:00     ` al johnston
1998-11-05  0:00       ` Stephen Leake
1998-11-05  0:00       ` dewar
1998-11-05  0:00 ` Tucker Taft
1998-11-05  0:00   ` Tucker Taft
1998-11-05  0:00     ` al johnston
1998-11-05  0:00   ` Tucker Taft
1998-11-05  0:00     ` Mats Weber
1998-11-05  0:00       ` Tucker Taft [this message]
1998-11-05  0:00         ` al johnston
1998-11-05  0:00           ` Tucker Taft
1998-11-06  0:00             ` Mats Weber
1998-11-06  0:00               ` Tucker Taft
replies disabled

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