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,26639dcc06d45917,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-20 09:20:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!west.cox.net!cox.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail From: "Eric G. Miller" Subject: Array of unbounded strings, memory leakage? User-Agent: Pan/0.13.0 (The whole remains beautiful (Debian GNU/Linux)) Message-ID: Newsgroups: comp.lang.ada MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: Sun, 20 Oct 2002 16:20:34 GMT NNTP-Posting-Host: 216.119.10.71 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1035130834 216.119.10.71 (Sun, 20 Oct 2002 09:20:34 PDT) NNTP-Posting-Date: Sun, 20 Oct 2002 09:20:34 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:29963 Date: 2002-10-20T16:20:34+00:00 List-Id: I know the following isn't terribly efficient, but does the Resize procedure leak memory? I wrote a little package for reading/writing common delimited text file formats (tab, space, comma, etc...) and this is what I'm using to hold the split contents of each "record". If I understand correctly, it shouldn't leak, since I never "new" the individual unbounded strings. Say I have: type UBString_Array is array (Positive range <>) of Ada.Strings.Unbounded.Unbounded_String; type UBStrArray_Access is access UBString_Array; ... procedure Free is new Ada.Unchecked_Deallocation ( UBString_Array, UBStrArray_Access); procedure Resize (Fields : in out UBStrArray_Access; Size : Natural) is Tmp : UBStrArray_Access := null; Old_Size : Natural := 0; begin if Fields /= null then Old_Size := Fields'Length; end if; if Size > 0 then Tmp := new UBString_Array(1..Size); if Size <= Old_Size then Tmp(1..Size) := Fields(1..Size); else Tmp(1..Old_Size) := Fields(1..Old_Size); for J in Old_Size + 1 .. Size loop Tmp(J) := Ada.Strings.Unbounded.Null_Unbounded_String; end loop; end if; end if; Free (Fields); Fields := Tmp; end Resize;