[Vala] ArrayList reference count question
- From: Donn Ingle <donn ingle gmail com>
- To: vala-list gnome org
- Subject: [Vala] ArrayList reference count question
- Date: Sat, 26 Oct 2013 13:24:43 +0200
Hello again,
Another newb question about ref counts:
---
using Gee;
public class Obj : Object {
public string id;
public Obj(string id) {
this.id = id;
}
}
public void foo( Obj o) {
//It seems "o" here is a pointer - i.e. it has not inc the ref_count.
stdout.printf("In func foo, o ref:%u\n",o.ref_count);
}
int main() {
var L = new ArrayList<Obj>();
L.add(new Obj("A"));
//Why does the next line show a ref_count of 2 for L[0]?
stdout.printf("Directly L[0].ref_count:%u\n",L[0].ref_count);
//sundry test of function args.
foo( L[0] );
return 0;
}
---
Question in the code regarding the number of refs to the Obj instance.
\d
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]