[Zodb-checkins] CVS: Zope/lib/Components/ExtensionClass/src - Acquisition.c:1.54.10.1 ExtensionClass.c:1.49.10.1 ThreadLock.c:1.10.26.1

Jeremy Hylton jeremy@zope.com
Fri, 8 Mar 2002 14:12:56 -0500


Update of /cvs-repository/Zope/lib/Components/ExtensionClass/src
In directory cvs.zope.org:/tmp/cvs-serv14812

Modified Files:
      Tag: Zope-2_5-branch
	Acquisition.c ExtensionClass.c ThreadLock.c 
Log Message:
Backport bug fixes from trunk.  

Original checkin message follows:

(Possibly) correct use of Python memory APIs.

Fix SF bug #516768 reported by Dave Wallace.

Replace use of PyMem_DEL() with PyObject_Del() on object dealloc
functions.  The use of PyMem_DEL() is incorrect for object
deallocation, because it only ever calls the low-level free().  If a
custom allocator like pymalloc is used, it needs to be called to free
the memory.

Also replace bare malloc() and realloc() with PyMem_Malloc() and
PyMem_Realloc().  I think this isn't a strict bug fix, but a would be
nice.  It guarantees that BTrees objects get their memory from the
same allocator as the Python core.


=== Zope/lib/Components/ExtensionClass/src/Acquisition.c 1.54 => 1.54.10.1 ===
   else 
     {
-      PyMem_DEL(self);
+      PyObject_DEL(self);
     }
 }
 


=== Zope/lib/Components/ExtensionClass/src/ExtensionClass.c 1.49 => 1.49.10.1 ===
       Py_XDECREF(self->ob_type);
   }
-  PyMem_DEL(self);
+  PyObject_DEL(self);
 }
   
 static PyObject *
@@ -3074,7 +3074,7 @@
   UNLESS(base_dealloced) 
     {
       Py_DECREF(self->ob_type);
-      PyMem_DEL(self);
+      PyObject_DEL(self);
     }
 
   PyErr_Restore(t,v,tb);


=== Zope/lib/Components/ExtensionClass/src/ThreadLock.c 1.10 => 1.10.26.1 ===
   free_lock(self->lock);
 #endif
-  PyMem_DEL(self);
+  PyObject_DEL(self);
 }
 
 static PyObject *
@@ -274,7 +274,7 @@
 #ifdef WITH_THREAD
   self->lock = allocate_lock();
   if (self->lock == NULL) {
-    PyMem_DEL(self);
+    PyObject_DEL(self);
     self = NULL;
     PyErr_SetString(ErrorObject, "can't allocate lock");
   }