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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,248d2a0e5d01f107 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-10 17:21:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-05!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: achrist@easystreet.com Newsgroups: comp.lang.ada Subject: Re: Problem with Gnat.Dynamic_Tables Date: Wed, 10 Jul 2002 17:19:40 -0700 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <3D2CCF1C.8CA24AC1@easystreet.com> X-Mailer: Mozilla 4.79 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 References: <3D2B6BFB.D4468F57@easystreet.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:27001 Date: 2002-07-10T17:19:40-07:00 List-Id: Update: I got several kinds of memory errors and problems trying to use the Gnat Dynamic_Tables, so I tried switching to the mw_components Dynamic_Arrays. This package was similar enough that I could pretty much substitute the operations of one package for the other, just about one-for-one. That fixed everthing; the whole program works fine now. Al achrist@easystreet.com wrote: > > I've got a problem with Gnat.Dynamic_Tables. I want to use a dynamic > table of Ada.Strings.Unbounded.Unbounded_String data. To do this I > use: > > package Csv_Table is new Gnat.Dynamic_Tables( > Ada.Strings.Unbounded.Unbounded_String, > Csv_Row_Index_Type, > 0, 1200, 100 > ); > > type Object is access all Csv_Table.Instance; > > I set the size of the table with > > Csv_Table.Increment_Last( The_Table.all ); > > Before I assign to elements in the table, I check that the > subscript is equal to Last. This all works, but sometimes > it crashes with a program error in the assignment: > > procedure Add_Row ( > The_Table : in out Object; > New_Row : String ) is > begin > Csv_Table.Increment_Last( The_Table.all ); > The_Table.Table( Csv_Table.Last(The_Table.all) ) > := Ada.Strings.Unbounded.To_Unbounded_String(New_Row); > end Add_Row; > > The statement number that comes back from the crash is a-strunb.ads 368. > This is (gnat 3.14p1) the statement of the declaration of the > Unbounded_String type. I'm loading the data from a file, and the crash > happens around row 169 of my data, ie I get 168 values into the table > fine, then it crashes. The crash happens in the statement that > attempts to assign the unbounded string to the table entry. > > I see in the Gnat.Dynamic_Tables comments that no initialization of > the array elements is done. Does an unbounded_string need some > initialization? If so, how can I make this work? > > TIA for any help. > > Al