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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!i6g2000yqj.googlegroups.com!not-for-mail From: sjw Newsgroups: comp.lang.ada Subject: Re: Deallocation of Unbounded_String Date: Sat, 25 Jul 2009 10:09:30 -0700 (PDT) Organization: http://groups.google.com Message-ID: <407b6ec0-0e40-4ffe-a8a0-de475f1527ab@i6g2000yqj.googlegroups.com> References: NNTP-Posting-Host: 82.20.239.89 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1248541770 10023 127.0.0.1 (25 Jul 2009 17:09:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 25 Jul 2009 17:09:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i6g2000yqj.googlegroups.com; posting-host=82.20.239.89; posting-account=_RXWmAoAAADQS3ojtLFDmTNJCT0N2R4U User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:6375 Date: 2009-07-25T10:09:30-07:00 List-Id: 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 My_Unbounded_String :=3D Ada.Strings.Unbounded.Null_Unbounded_String; > 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.