mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
* psycopg/typecast.c (typecast_traverse): implement cyclic GC
traversal for typecasters.
This commit is contained in:
parent
a39fb19eb9
commit
bbd101bb7e
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2008-05-28 James Henstridge <james@jamesh.id.au>
|
||||
|
||||
* psycopg/typecast.c (typecast_traverse): implement cyclic GC
|
||||
traversal for typecasters.
|
||||
|
||||
* psycopg/connection_type.c:
|
||||
* psycopg/cursor_type.c: add support for cyclic GC traversal (no
|
||||
support for clearing).
|
||||
|
||||
* psycopg/python.h: add definitions for Py_CLEAR() and Py_VISIT()
|
||||
for compatibility with old versions of Python.
|
||||
|
||||
2008-05-19 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/cursor_type.c: fixed memory leak in .executemany(); on
|
||||
|
|
|
@ -382,11 +382,28 @@ typecast_dealloc(PyObject *obj)
|
|||
{
|
||||
typecastObject *self = (typecastObject*)obj;
|
||||
|
||||
Py_XDECREF(self->values);
|
||||
Py_XDECREF(self->name);
|
||||
Py_XDECREF(self->pcast);
|
||||
Py_CLEAR(self->values);
|
||||
Py_CLEAR(self->name);
|
||||
Py_CLEAR(self->pcast);
|
||||
|
||||
PyObject_Del(self);
|
||||
obj->ob_type->tp_free(obj);
|
||||
}
|
||||
|
||||
static int
|
||||
typecast_traverse(PyObject *obj, visitproc visit, void *arg)
|
||||
{
|
||||
typecastObject *self = (typecastObject*)obj;
|
||||
|
||||
Py_VISIT(self->values);
|
||||
Py_VISIT(self->name);
|
||||
Py_VISIT(self->pcast);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
typecast_del(void *self)
|
||||
{
|
||||
PyObject_GC_Del(self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -427,10 +444,11 @@ PyTypeObject typecastType = {
|
|||
0, /*tp_setattro*/
|
||||
0, /*tp_as_buffer*/
|
||||
|
||||
Py_TPFLAGS_HAVE_RICHCOMPARE, /*tp_flags*/
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_RICHCOMPARE |
|
||||
Py_TPFLAGS_HAVE_GC, /*tp_flags*/
|
||||
"psycopg type-casting object", /*tp_doc*/
|
||||
|
||||
0, /*tp_traverse*/
|
||||
typecast_traverse, /*tp_traverse*/
|
||||
0, /*tp_clear*/
|
||||
|
||||
typecast_richcompare, /*tp_richcompare*/
|
||||
|
@ -454,7 +472,7 @@ PyTypeObject typecastType = {
|
|||
0, /*tp_init*/
|
||||
0, /*tp_alloc will be set to PyType_GenericAlloc in module init*/
|
||||
0, /*tp_new*/
|
||||
0, /*tp_free Low-level free-memory routine */
|
||||
typecast_del, /*tp_free Low-level free-memory routine */
|
||||
0, /*tp_is_gc For PyObject_IS_GC */
|
||||
0, /*tp_bases*/
|
||||
0, /*tp_mro method resolution order */
|
||||
|
@ -468,7 +486,7 @@ typecast_new(PyObject *name, PyObject *values, PyObject *cast, PyObject *base)
|
|||
{
|
||||
typecastObject *obj;
|
||||
|
||||
obj = PyObject_NEW(typecastObject, &typecastType);
|
||||
obj = PyObject_GC_New(typecastObject, &typecastType);
|
||||
if (obj == NULL) return NULL;
|
||||
|
||||
Dprintf("typecast_new: new type at = %p, refcnt = " FORMAT_CODE_PY_SSIZE_T,
|
||||
|
@ -498,6 +516,8 @@ typecast_new(PyObject *name, PyObject *values, PyObject *cast, PyObject *base)
|
|||
obj->pcast = cast;
|
||||
}
|
||||
|
||||
PyObject_GC_Track(obj);
|
||||
|
||||
Dprintf("typecast_new: typecast object created at %p", obj);
|
||||
|
||||
return (PyObject *)obj;
|
||||
|
|
Loading…
Reference in New Issue
Block a user