From: chris <spamoff.danx@ntlworld.com>
Subject: Re: Free-ing memory: not springing leaks?
Date: Sun, 14 Sep 2003 14:14:29 +0200
Date: 2003-09-14T14:14:29+02:00 [thread overview]
Message-ID: <WMZ8b.2006$WI3.27207@newsfep4-glfd.server.ntli.net> (raw)
In-Reply-To: <uwucb8rbh.fsf@earthlink.net>
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
next prev parent reply other threads:[~2003-09-14 12:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-13 21:33 Free-ing memory: not springing leaks? chris
2003-09-14 1:10 ` Matthew Heaney
2003-09-14 11:02 ` chris
2003-09-14 12:51 ` Matthew Heaney
2003-09-14 12:14 ` chris [this message]
2003-09-14 14:24 ` Ludovic Brenta
2003-09-14 19:00 ` chris
2003-09-14 16:06 ` Simon Wright
2003-09-15 7:13 ` Martin Krischik
2003-09-18 20:15 ` Warren W. Gay VE3WWG
2003-09-19 3:02 ` Hyman Rosen
2003-09-19 13:07 ` Warren W. Gay VE3WWG
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox