summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2010-02-23 20:32:43 (GMT)
committerThomas Heller <theller@ctypes.org>2010-02-23 20:32:43 (GMT)
commit41c5d2fb56b25a132015853b2612f012ca39be83 (patch)
treeb582ead4677c73dcc8643c1968f02c40c15b5a00 /Modules/_ctypes
parentf99f67be01f23d5f59e058d7286f05b009c02c9a (diff)
downloadcpython-41c5d2fb56b25a132015853b2612f012ca39be83.zip
cpython-41c5d2fb56b25a132015853b2612f012ca39be83.tar.gz
cpython-41c5d2fb56b25a132015853b2612f012ca39be83.tar.bz2
Merged revisions 78382 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r78382 | thomas.heller | 2010-02-23 21:25:02 +0100 (Di, 23 Feb 2010) | 11 lines Merged revisions 78380 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78380 | thomas.heller | 2010-02-23 21:11:44 +0100 (Di, 23 Feb 2010) | 4 lines ctypes CThunkObject was not registered correctly with the cycle garbage collector, leading to possible leaks when using callback functions. ........ ................
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/callbacks.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 328b10f..9b2cd3f 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -18,7 +18,7 @@ CThunkObject_dealloc(PyObject *_self)
Py_XDECREF(self->restype);
if (self->pcl)
_ctypes_free_closure(self->pcl);
- PyObject_Del(self);
+ PyObject_GC_Del(self);
}
static int
@@ -61,7 +61,7 @@ PyTypeObject PyCThunk_Type = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
"CThunkObject", /* tp_doc */
CThunkObject_traverse, /* tp_traverse */
CThunkObject_clear, /* tp_clear */
@@ -364,7 +364,7 @@ static CThunkObject* CThunkObject_new(Py_ssize_t nArgs)
CThunkObject *p;
int i;
- p = PyObject_NewVar(CThunkObject, &PyCThunk_Type, nArgs);
+ p = PyObject_GC_NewVar(CThunkObject, &PyCThunk_Type, nArgs);
if (p == NULL) {
PyErr_NoMemory();
return NULL;
@@ -379,6 +379,7 @@ static CThunkObject* CThunkObject_new(Py_ssize_t nArgs)
for (i = 0; i < nArgs + 1; ++i)
p->atypes[i] = NULL;
+ PyObject_GC_Track((PyObject *)p);
return p;
}