[Python-checkins] CVS: python/dist/src/Objects methodobject.c,2.33,2.34
Neil Schemenauer
nascheme@users.sourceforge.net
Thu, 12 Jul 2001 06:27:37 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv1613/Objects
Modified Files:
methodobject.c
Log Message:
GC for method objects.
Index: methodobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v
retrieving revision 2.33
retrieving revision 2.34
diff -C2 -r2.33 -r2.34
*** methodobject.c 2000/09/01 23:29:27 2.33
--- methodobject.c 2001/07/12 13:27:35 2.34
***************
*** 25,28 ****
--- 25,29 ----
Py_XINCREF(self);
op->m_self = self;
+ PyObject_GC_Init(op);
return (PyObject *)op;
}
***************
*** 63,66 ****
--- 64,68 ----
meth_dealloc(PyCFunctionObject *m)
{
+ PyObject_GC_Fini(m);
Py_XDECREF(m->m_self);
m->m_self = (PyObject *)free_list;
***************
*** 68,71 ****
--- 70,82 ----
}
+ static int
+ meth_traverse(PyCFunctionObject *m, visitproc visit, void *arg)
+ {
+ if (m->m_self != NULL)
+ return visit(m->m_self, arg);
+ else
+ return 0;
+ }
+
static PyObject *
meth_getattr(PyCFunctionObject *m, char *name)
***************
*** 153,168 ****
0,
"builtin_function_or_method",
! sizeof(PyCFunctionObject),
0,
! (destructor)meth_dealloc, /*tp_dealloc*/
! 0, /*tp_print*/
! (getattrfunc)meth_getattr, /*tp_getattr*/
! 0, /*tp_setattr*/
! (cmpfunc)meth_compare, /*tp_compare*/
! (reprfunc)meth_repr, /*tp_repr*/
! 0, /*tp_as_number*/
! 0, /*tp_as_sequence*/
! 0, /*tp_as_mapping*/
! (hashfunc)meth_hash, /*tp_hash*/
};
--- 164,187 ----
0,
"builtin_function_or_method",
! sizeof(PyCFunctionObject) + PyGC_HEAD_SIZE,
0,
! (destructor)meth_dealloc, /* tp_dealloc */
! 0, /* tp_print */
! (getattrfunc)meth_getattr, /* tp_getattr */
! 0, /* tp_setattr */
! (cmpfunc)meth_compare, /* tp_compare */
! (reprfunc)meth_repr, /* tp_repr */
! 0, /* tp_as_number */
! 0, /* tp_as_sequence */
! 0, /* tp_as_mapping */
! (hashfunc)meth_hash, /* tp_hash */
! 0, /* tp_call */
! 0, /* tp_str */
! 0, /* tp_getattro */
! 0, /* tp_setattro */
! 0, /* tp_as_buffer */
! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /* tp_flags */
! 0, /* tp_doc */
! (traverseproc)meth_traverse, /* tp_traverse */
};
***************
*** 246,249 ****
--- 265,269 ----
PyCFunctionObject *v = free_list;
free_list = (PyCFunctionObject *)(v->m_self);
+ v = (PyCFunctionObject *) PyObject_AS_GC(v);
PyObject_DEL(v);
}