Re: [Vala] Passing Ownership Help
- From: Luca Bruno <lethalman88 gmail com>
- To: Peter Cartwright <peter public use gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Passing Ownership Help
- Date: Sat, 9 Jul 2011 19:44:27 +0200
On Sun, Jul 10, 2011 at 02:36:23AM +0900, Peter Cartwright wrote:
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.
You're still owning p in that scope. You want List.add ((owned) p);
--
http://www.debian.org - The Universal Operating System
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]