[Vala] Passing Ownership Help

Hi guys,

I am trying to understand how a function can take ownership of an object
passed into it. According to documentation it should be like below:

MyList.add (owned Person p) {
  _first = (owned) p;

Person p = new Person ("Bobby");
List.add (p);
stdout.printf ("%u\n", p.ref_count);

But when I do it like this and check the reference count of p, it is equal
to 2... shouldn't it be 1? I want the list to be the new owner of P.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]