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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,bb7708f0d606e785 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!y19g2000yqy.googlegroups.com!not-for-mail From: vlc Newsgroups: comp.lang.ada Subject: Re: Deallocation of Unbounded_String Date: Sat, 25 Jul 2009 10:16:52 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8f0f5ced-6596-49bd-a433-e08643aaca6a@y19g2000yqy.googlegroups.com> References: <407b6ec0-0e40-4ffe-a8a0-de475f1527ab@i6g2000yqj.googlegroups.com> NNTP-Posting-Host: 87.221.73.228 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1248542212 11689 127.0.0.1 (25 Jul 2009 17:16:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 25 Jul 2009 17:16:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y19g2000yqy.googlegroups.com; posting-host=87.221.73.228; posting-account=ROuOHgoAAABopjDuvPBd02HgYVR-VCZk User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.64 (X11; Linux i686; U; en) Presto/2.1.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:6376 Date: 2009-07-25T10:16:52-07:00 List-Id: On Jul 25, 7:09=A0pm, sjw wrote: > On Jul 25, 5:37=A0pm, vlc > wrote: > > > when using Unbounded_String, is it necessary to deallocate instances > > of Unbounded_String after use or is there a kind of garbage collector > > implemented? > > Unbounded_Strings are controlled, and look after their own memory when > they go out of scope or are overwritten. > > If you had a variable currently holding a really huge unbounded string > which you needed to keep in scope you could free its memory by saying > > =A0 =A0My_Unbounded_String :=3D Ada.Strings.Unbounded.Null_Unbounded_Stri= ng; > > > There is a "Free" function in Ada.Strings.Unbounded, but it takes an > > access to String as argument, not an access to Unbounded_String. > > Hadn't noticed that; no idea why it's there (might be some use in > Ada.Strings.Fixed?) > > > If I'm supposed to use this "Free" function to deallocate the memory > > of my unused Unbounded_String, what is the correct usage of this > > function (typecast of "access Unbounded_String" to "access String")? > > Very Bad Things would happen if you did this. The memory layout of the > two types of object is going to be entirely different. An > Unbounded_String is likely to be chained through a list of objects to > be finalized when the scope is left - you interfere with that sort of > construct at your peril. Thanks a lot for your help!