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,cc05aeb5e0d8b475 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-14 06:10:15 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!news.mailgate.org!newsfeed.stueberl.de!newspeer1-gui.server.ntli.net!ntli.net!newsfep4-glfd.server.ntli.net.POSTED!53ab2750!not-for-mail From: chris User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030903 Thunderbird/0.2 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Free-ing memory: not springing leaks? References: <2TM8b.1013$Nb6.297@newsfep4-winn.server.ntli.net> <9JY8b.1963$WI3.25442@newsfep4-glfd.server.ntli.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sun, 14 Sep 2003 14:14:29 +0200 NNTP-Posting-Host: 81.98.236.164 X-Complaints-To: abuse@ntlworld.com X-Trace: newsfep4-glfd.server.ntli.net 1063545014 81.98.236.164 (Sun, 14 Sep 2003 14:10:14 BST) NNTP-Posting-Date: Sun, 14 Sep 2003 14:10:14 BST Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:42477 Date: 2003-09-14T14:14:29+02:00 List-Id: Matthew Heaney wrote: > chris.danx wrote: >>For example, the library loader for linux error mechanism is to return >>an error msg describing the problem. Once you have it appears to be >>your problem what you do with it. There is no call present in the >>library to return the memory. > > This is an Ada binding? Who wrote it? No it is a C library for loading libraries at runtime. Its' error handling returns errors as strings (customised to the library & call made) - though it'd be easier if it was ints, the errors can be for a variety of reasons but you need to parse them to handle them effectively! const char *dlerror(void); I wrote a binding to it, but did not know at the time free-ing C memory from Ada (with Interfaces.C.Strings.Free) was a no-no. The binding takes the error message, converts it to an Ada string, free's the memory of the C string (with Interfaces.C.Strings.Free) and raises an exception tagged with the Ada String. I will change this soon to use the native C compilers/libs "Free" (I forgot this when making the initial post. I have free'd c memory from ada before). > If you know it was malloc'd, then yes, just write a binding to free and > call that. And if you don't, then it's hit and miss? ... it figures. I wonder how C programmers deal with this :( Thanks for your help, it's much appreciated. Chris