[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees - BTreeTemplate.c:1.5

Tim Peters tim.one@comcast.net
Mon, 10 Jun 2002 22:39:06 -0400


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

Modified Files:
	BTreeTemplate.c 
Log Message:
BTree_grow():  eliminated needless casting.  Fixed places where an
error return let a newly allocated object leak; curiously, there was
one more of these in the Zope3 version of the code than on the trunk.


=== Zope3/lib/python/Persistence/BTrees/BTreeTemplate.c 1.4 => 1.5 ===
 	  return -1;
 
+      UNLESS(PER_USE(v)) {
+          Py_DECREF(e);
+          return -1;
+      }
+
       /* Now split between the original (v) and the new (e) at the midpoint*/
-      PyPersist_INCREF((PyPersistObject *)v);
-      if (!PyPersist_IS_STICKY((PyPersistObject *)v))
-	  return -1;
       if (SameType_Check(self, v))
           i = BTree_split((BTree *)v, -1, (BTree *)e);
       else
           i = bucket_split((Bucket *)v, -1, (Bucket *)e);
-      PyPersist_DECREF((Bucket *)v);
+      PER_ALLOW_DEACTIVATION(v);
 
-      if (i < 0)
+      if (i < 0) {
+          Py_DECREF(e);
           return -1;
+      }
 
       index++;
       d++;
@@ -270,7 +274,7 @@
 
   /* refcnt note:
 
-     It appears that d->value always has a refcnt of 2 in all paths,
+     It appears that d->child always has a refcnt of 2 in all paths,
      except possibly if BTree_split() is called.
   */