[Vala] Invalid pointer error with manual reference handling (g_free instead of g_slice_free)
- From: Amos Brocco <amos brocco gmail com>
- To: vala-list gnome org
- Subject: [Vala] Invalid pointer error with manual reference handling (g_free instead of g_slice_free)
- Date: Thu, 26 Aug 2010 11:45:04 +0200
I'm implementing a compact class with manual reference handling, following
the example given in http://live.gnome.org/Vala/ReferenceHandling):
[Compact]
[CCode (ref_function = "foo_up", unref_function = "foo_down")]
public class Foo {
public int ref_count = 1;
public unowned Foo up () {
++ref_count;
return this;
}
public void down () {
if (--ref_count == 0) {
delete (void*) this;
}
}
public void method () { }
}
void main () {
Foo foo = new Foo (); // allocate, ref
foo.method ();
Foo bar = foo; // ref
} // unref, unref => free
The program crashes when doing "delete (void*) this;" because the code is
translated to
g_free ((void*) self);
instead of a
g_slice_free (GryaFoo, self);
Is it a compiler error?
cheers
A.
Note:
this is the same problem as reported by someone on ubuntu forums
http://ubuntuforums.org/showthread.php?p=9728355... don't known if a message
was already posted here... if so, sorry for the duplication :P
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]