christof
Joined: 09 Jan 2008 Posts: 7 Location: Hamburg/ Germany
|
Posted: Fri Feb 08, 2008 2:48 am Post subject: GC problem? |
|
|
I am a beginner with D and celerid, so forgive if this seems to be a stupid question.
I am trying to wrap a tree structure to python. Each tree node can hold a couple of childs. It works, when a python reference to each node exists, but crashes otherwise.
Lets say:
Code: | subexpr1 = dtables.Equal(0)
subexpr2 = dtables.In([2,3, 4])
expr1 = dtables.Or(subexpr1, subexpr2)
expr2 = dtables.Or(dtables.Equal(0), dtables.In([2,3, 4])) |
So for expr1 there python references to the child nodes exist, for expr2 not.
The node definition is as
Code: | class In : Expression
{
PyObject* set;
this(PyObject* value)
{
this.set = PySet_New(value);
Py_INCREF(this.set);
}
bit eval_row(Table table, int position)
{
if (PySet_Contains(set, table[position]))
return true;
else
return false;
}
}
|
Expr1 works, whereas for expr2 an Access Violation occures. I think this is a problem related to garbage collection. What can I do?
Thanks,
Christof |
|