summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-06-23 14:18:11 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-06-23 14:18:11 (GMT)
commit8caad49c30d2f9ecd09c8838bb691360e40c2665 (patch)
tree367db742417367edaea6a4dee1eea3ff2885d3db /Objects/dictobject.c
parenta392dcb2117739ad0dc7f67bd550083ee860226b (diff)
downloadcpython-8caad49c30d2f9ecd09c8838bb691360e40c2665.zip
cpython-8caad49c30d2f9ecd09c8838bb691360e40c2665.tar.gz
cpython-8caad49c30d2f9ecd09c8838bb691360e40c2665.tar.bz2
Round 1 of Neil Schemenauer's GC patches:
This patch adds the type methods traverse and clear necessary for GC implementation.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 6e7fa3d..2d33b92 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1038,6 +1038,31 @@ dict_clear(mp, args)
return Py_None;
}
+static int
+dict_traverse(PyObject *op, visitproc visit, void *arg)
+{
+ int i = 0, err;
+ PyObject *pk;
+ PyObject *pv;
+
+ while (PyDict_Next(op, &i, &pk, &pv)) {
+ err = visit(pk, arg);
+ if (err)
+ return err;
+ err = visit(pv, arg);
+ if (err)
+ return err;
+ }
+ return 0;
+}
+
+static int
+dict_tp_clear(PyObject *op)
+{
+ PyDict_Clear(op);
+ return 0;
+}
+
static PyMethodDef mapp_methods[] = {
{"has_key", (PyCFunction)dict_has_key, METH_VARARGS},
{"keys", (PyCFunction)dict_keys},
@@ -1073,6 +1098,16 @@ PyTypeObject PyDict_Type = {
0, /*tp_as_number*/
0, /*tp_as_sequence*/
&dict_as_mapping, /*tp_as_mapping*/
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /* tp_doc */
+ (traverseproc)dict_traverse, /* tp_traverse */
+ (inquiry)dict_tp_clear, /* tp_clear */
};
/* For backward compatibility with old dictionary interface */