[Zope-Checkins] CVS: Zope/lib/python/ExtensionClass -
ExtensionClass.h:1.1.2.5
Jim Fulton
cvs-admin at zope.org
Wed Oct 29 10:19:03 EST 2003
Update of /cvs-repository/Zope/lib/python/ExtensionClass
In directory cvs.zope.org:/tmp/cvs-serv4568
Modified Files:
Tag: zodb33-devel-branch
ExtensionClass.h
Log Message:
Made an evil macro hack much less evil by making the macro much
smarter. When PyMem_DEL (and PyObject_DEL) is used in an extension
class, we need to call tp_free rather than PyObject_FREE.
=== Zope/lib/python/ExtensionClass/ExtensionClass.h 1.1.2.4 => 1.1.2.5 ===
--- Zope/lib/python/ExtensionClass/ExtensionClass.h:1.1.2.4 Wed Oct 29 06:09:17 2003
+++ Zope/lib/python/ExtensionClass/ExtensionClass.h Wed Oct 29 10:19:01 2003
@@ -246,7 +246,13 @@
((PyExtensionClassCAPI != NULL) || \
(PyExtensionClassCAPI = PyCObject_Import("ExtensionClass","CAPI2")))
-#define PyMem_DEL(O) (O)->ob_type->tp_free((PyObject*)(O))
-#define PyObject_DEL(O) (O)->ob_type->tp_free((PyObject*)(O))
+#define PyMem_DEL(O) \
+ if (((O)->ob_type->tp_flags & Py_TPFLAGS_HAVE_CLASS) \
+ && ((O)->ob_type->tp_free != NULL)) \
+ (O)->ob_type->tp_free((PyObject*)(O)); \
+ else \
+ PyObject_FREE((O));
+
+#define PyObject_DEL(O) PyMem_DEL(O)
#endif /* EXTENSIONCLASS_H */
More information about the Zope-Checkins
mailing list