Re: [Vala] After transfering ownership of compact class, Vala still call free method
- From: Luca Bruno <lethalman88 gmail com>
- To: Tal Hadad <tal_hd hotmail com>
- Cc: Vala Mail List <vala-list gnome org>
- Subject: Re: [Vala] After transfering ownership of compact class, Vala still call free method
- Date: Thu, 24 May 2012 12:26:35 +0200
On Tue, May 22, 2012 at 6:59 PM, Tal Hadad <tal_hd hotmail com> wrote:
I'm trying to write a nodes system which is tree based. Not matter how it
works, this is part of the code:
NodesRoot root = new NodesRoot ();
stdout.printf ("Root created\n");
unowned NodesUnit unit = root.prepend_unit ();
if (unit == null)
stderr.printf ("Not working!");
stdout.printf ("Unit created\n");
Node node = new Node ();
stdout.printf ("Node created\n");
unit.prepend_node ((owned)node);
stdout.printf ("Node prepended\n");
node = null;// Ensure that node will be free before root if it will.
stdout.printf ("Node is null\n");
this is the runtime:
Root created
Unit created
Node created
Node prepended
Node is null
*** glibc detected *** ./simple_triangle: free(): invalid pointer:
0x000000000190cc40 ***
======= Backtrace: =========
(big memory trace)
I've noticed that in the generated C code, node get freed by Vala.
Why is it happening if I transferred ownership for the method?
Doesn't the ownership transferring make the original unowned?
Ownership transfer will nullify the variable, so that node=null is useless.
Then vala shouldn't free a null variable. The problem must be elsewhere,
try getting a proper backtrace.
--
www.debian.org - The Universal Operating System
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]