Hi,
I have a problem because I did not realy get yet when do Py_INCREF or to Py_DECREF.
I build a class type that covers a PyObject*-Array. Now I wrote a function like that:
static PyObject *
get_first(MyObject *self) {
PyObject *res = NULL;
if (!self->size)
return NULL;
res = self->items[0];
// Py_INCREF(res);
return res;
}
I don't really know why I should use Py_INCREF(res) but if I don't do it I'll get a segmentation fault after calling the function several times. This doesn't happen if i put in a Py_INCREF(res).
I thought I don't have to care about what the user does with the result. Do I always have to Py_INCREF my results???