[Zodb-checkins] CVS: Zope3/lib/python/Persistence/BTrees - BucketTemplate.c:1.1.2.14
Jeremy Hylton
jeremy@zope.com
Wed, 5 Jun 2002 18:02:15 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv16835
Modified Files:
Tag: Zope-3x-branch
BucketTemplate.c
Log Message:
Several fixes to bucket traverse.
Visit the po_ slots by calling tp_traverse() on the base class.
Start the for loop at the right index.
Don't dereference self.values if it is NULL.
=== Zope3/lib/python/Persistence/BTrees/BucketTemplate.c 1.1.2.13 => 1.1.2.14 ===
return err; \
}
- VISIT(self->po_dm);
- VISIT(self->po_oid);
- VISIT(self->po_serial);
+
+ PyPersist_BASE_TYPE->tp_traverse(self, visit, arg);
- VISIT(self->next);
+ if (self->next)
+ VISIT(self->next);
/* XXX should implement more efficiently: don't iterate at all if
the key or value isn't an object. Don't dereference the
pointer if it doesn't point to an object.
*/
- /* XXX BUG This loop appears to make out-of-bounds references
- (when i = self->len, on the first trip).
- */
- for (i = self->len; i >= 0; i--) {
+ for (i = self->len - 1; i >= 0; i--) {
VISIT(KEY_IF_OBJECT(self->keys[i]));
- VISIT(VALUE_IF_OBJECT(self->values[i]));
+ if (self->values)
+ VISIT(VALUE_IF_OBJECT(self->values[i]));
}
#undef VISIT