On Tue, May 22, 2012 at 6:59 PM, Tal Hadad <tal...@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
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to