summaryrefslogtreecommitdiff
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-06-23 14:18:11 +0000
committerJeremy Hylton <jeremy@alum.mit.edu>2000-06-23 14:18:11 +0000
commit8caad49c30d2f9ecd09c8838bb691360e40c2665 (patch)
tree367db742417367edaea6a4dee1eea3ff2885d3db /Objects/tupleobject.c
parenta392dcb2117739ad0dc7f67bd550083ee860226b (diff)
downloadcpython-git-8caad49c30d2f9ecd09c8838bb691360e40c2665.tar.gz
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/tupleobject.c')
-rw-r--r--Objects/tupleobject.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index f89fa365a9..bbb56b1adc 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -420,6 +420,23 @@ tuplerepeat(a, n)
return (PyObject *) np;
}
+static int
+tupletraverse(PyTupleObject *o, visitproc visit, void *arg)
+{
+ int i, err;
+ PyObject *x;
+
+ for (i = o->ob_size; --i >= 0; ) {
+ x = o->ob_item[i];
+ if (x != NULL) {
+ err = visit(x, arg);
+ if (err)
+ return err;
+ }
+ }
+ return 0;
+}
+
static PySequenceMethods tuple_as_sequence = {
(inquiry)tuplelength, /*sq_length*/
(binaryfunc)tupleconcat, /*sq_concat*/
@@ -453,6 +470,8 @@ PyTypeObject PyTuple_Type = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc*/
+ (traverseproc)tupletraverse, /* tp_traverse */
};
/* The following function breaks the notion that tuples are immutable: