如果我有以下配置:
#include "custom.hpp"
typedef struct
{
PyObject_HEAD
FastFile* cppobjectpointer;
}
PyFastFile;
static int PyFastFile_init(PyFastFile *self, PyObject *args, PyObject *kwds) {
self->cppobjectpointer = new FastFile( filepath );
return 0;
}
如何释放我的cppobjectpointer
?你知道吗
我应该这样做:
static void PyFastFile_dealloc(PyFastFile * self)
{
delete self->cppobjectpointer;
Py_TYPE(self)->tp_free( (PyObject *) self );
}
或者这个:
static void PyFastFile_dealloc(PyFastFile * self)
{
Py_XDECREF(self->cppobjectpointer);
Py_TYPE(self)->tp_free( (PyObject *) self );
}
参考文献:
目前没有回答
相关问题 更多 >
编程相关推荐