[Zodb-checkins] CVS: Zope3/lib/python/Persistence/BTrees - BTreeTemplate.c:1.1.2.14

Jeremy Hylton jeremy@zope.com
Wed, 5 Jun 2002 18:24:41 -0400


Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv24605

Modified Files:
      Tag: Zope-3x-branch
	BTreeTemplate.c 
Log Message:
Fix BTree traverse code in much the same way as Bucket_traverse().

Don't visit the first key, because it's garbage.
Check firstbucket pointer before visiting it.
Visit the po_ slots using the base class traverse.


=== Zope3/lib/python/Persistence/BTrees/BTreeTemplate.c 1.1.2.13 => 1.1.2.14 ===
     int err, i, l;
 
+    err = PyPersist_BASE_TYPE->tp_traverse((PyObject *)self, visit, arg);
+    if (err)
+	return err;
+
 #define VISIT(SLOT) \
     if (SLOT) { \
 	err = visit((PyObject *)(SLOT), arg); \
 	if (err) \
 		     return err; \
     }
-    /* Visit the basic persistence slots */
-    VISIT(self->po_dm);
-    VISIT(self->po_oid);
-    VISIT(self->po_serial);
 
-    VISIT(self->firstbucket);
-    for (i = 0, l = self->len; i < l; i++) {
+    if (self->firstbucket)
+	VISIT(self->firstbucket);
+    /* The first bucket is garbage.  Don't visit it. */
+    for (i = 1, l = self->len; i < l; i++) {
 	VISIT(KEY_IF_OBJECT(self->data[i].key));
 	VISIT(self->data[i].child);
     }
@@ -1294,6 +1296,7 @@
 BTree_tp_clear(BTree *self)
 {
     _BTree_clear(self);
+    /* XXX use base class tp_clear */
     Py_XDECREF(self->po_dm);
     Py_XDECREF(self->po_oid);
     Py_XDECREF(self->po_serial);