[Zodb-checkins] CVS: StandaloneZODB/ZODB - coptimizations.c:1.13

Barry Warsaw barry@wooz.org
Thu, 8 Nov 2001 12:13:36 -0500


Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv7914/ZODB

Modified Files:
	coptimizations.c 
Log Message:
initcoptimizations(): Some cleanup of the initializer.  First be sure
to decref the revision string, added to the module dict with the keys
"__version__".  This fixes a small leaks detected by Insure.

Also, at the end of the function, we do a PyErr_Occurred() check and
throw a fatal error if true.  This makes this module's init function
more in line with other init functions in this package.


=== StandaloneZODB/ZODB/coptimizations.c 1.12 => 1.13 ===
 initcoptimizations(void)
 {
-  PyObject *m, *d;
+  PyObject *m, *d, *s;
   char *rev="$Revision$";
 
 #define make_string(S) if (! (py_ ## S=PyString_FromString(#S))) return
@@ -348,6 +348,11 @@
   persistent_idType.ob_type=&PyType_Type;
   PyDict_SetItemString(d,"persistent_idType", OBJECT(&persistent_idType));
 
-  PyDict_SetItemString(d, "__version__",
-		       PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));  
+  s = PyString_FromStringAndSize(rev+11,strlen(rev+11)-2);
+  PyDict_SetItemString(d, "__version__", s);
+  Py_XDECREF(s);
+
+  /* Check for errors */
+  if (PyErr_Occurred())
+    Py_FatalError("can't initialize module coptimizations");
 }