From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: Free-ing memory: not springing leaks?
Date: Sun, 14 Sep 2003 01:10:55 GMT
Date: 2003-09-14T01:10:55+00:00 [thread overview]
Message-ID: <uznh89nru.fsf@earthlink.net> (raw)
In-Reply-To: 2TM8b.1013$Nb6.297@newsfep4-winn.server.ntli.net
chris <spamoff.danx@ntlworld.com> writes:
> When you bind to c code, how do you deal with memory? I bound to a
> function in Lua,
>
> function Lua_Version return ICS.Chars_Ptr;
> pragma Import (C, Lua_Version);
>
> but upon free-ing the memory it gave a storage_error.
You only free memory on the Ada side that has been allocated on the Ada
side. If you have a ptr to memory that has been allocated on the C
side, there should also be a function to free that memory.
> How then, do you deal with memory leaks? If you bind to a c function
> and it allocates a chunk of memory and returns it, how do get rid of it
> and not cause leaks? Remove Free and no error occurs. Perhaps this is
> a special case?
See above.
> I vaguely recall reading somewhere that in general you shouldn't free C
> allocated memory from Ada, but perhaps I was mistaken?
No, you are correct: don't do that.
next prev parent reply other threads:[~2003-09-14 1:10 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 [this message]
2003-09-14 11:02 ` chris
2003-09-14 12:51 ` Matthew Heaney
2003-09-14 12:14 ` chris
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