Re: [Vala] Threads with return value... Isn't this a memory leak?
- From: Jan Hudec <bulb ucw cz>
- To: Marco Trevisan (Treviño) <mail 3v1n0 net>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Threads with return value... Isn't this a memory leak?
- Date: Tue, 4 Jan 2011 19:45:51 +0100
On Tue, Jan 04, 2011 at 16:30:38 +0100, Marco Trevisan (Treviño) wrote:
Consider this simple vala code, which uses some threads with return
value... Since int[] can't be a generics, I need to use an int pointer
for using an integer array as retourn value...
No, but a
class IntArray {
int[] data;
}
can. So unless you are forced to use exactly int* by some external library or
something, just wrap the array in an object and return that. Vala will than
do memory-management for you properly.
It works as expected, but... If you look at the generated C code, the
pointer returned by g_thread_join (t) is never free'd.
As you've been already told, pointers are not managed automatically. But
there's the 'delete' statement for that case.
--
Jan 'Bulb' Hudec <bulb ucw cz>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]