Commit 1fc6caac authored by Barry Warsaw's avatar Barry Warsaw

initcPickleCache(): 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.
parent 0efdedfe
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
static char cPickleCache_doc_string[] = static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n" "Defines the PickleCache used by ZODB Connection objects.\n"
"\n" "\n"
"$Id: cPickleCache.c,v 1.35 2001/11/06 19:37:00 jeremy Exp $\n"; "$Id: cPickleCache.c,v 1.36 2001/11/08 17:13:01 bwarsaw Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;} #define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E)) #define UNLESS(E) if(!(E))
...@@ -726,8 +726,8 @@ static struct PyMethodDef cCM_methods[] = { ...@@ -726,8 +726,8 @@ static struct PyMethodDef cCM_methods[] = {
void void
initcPickleCache(void) initcPickleCache(void)
{ {
PyObject *m, *d; PyObject *m, *d, *s;
char *rev="$Revision: 1.35 $"; char *rev="$Revision: 1.36 $";
Cctype.ob_type=&PyType_Type; Cctype.ob_type=&PyType_Type;
...@@ -742,6 +742,11 @@ initcPickleCache(void) ...@@ -742,6 +742,11 @@ initcPickleCache(void)
py__p_jar=PyString_FromString("_p_jar"); py__p_jar=PyString_FromString("_p_jar");
py__p_changed=PyString_FromString("_p_changed"); py__p_changed=PyString_FromString("_p_changed");
PyDict_SetItemString(d,"__version__", s = PyString_FromStringAndSize(rev+11,strlen(rev+11)-2);
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 cPickleCache");
} }
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
static char cPickleCache_doc_string[] = static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n" "Defines the PickleCache used by ZODB Connection objects.\n"
"\n" "\n"
"$Id: cPickleCache.c,v 1.35 2001/11/06 19:37:00 jeremy Exp $\n"; "$Id: cPickleCache.c,v 1.36 2001/11/08 17:13:01 bwarsaw Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;} #define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E)) #define UNLESS(E) if(!(E))
...@@ -726,8 +726,8 @@ static struct PyMethodDef cCM_methods[] = { ...@@ -726,8 +726,8 @@ static struct PyMethodDef cCM_methods[] = {
void void
initcPickleCache(void) initcPickleCache(void)
{ {
PyObject *m, *d; PyObject *m, *d, *s;
char *rev="$Revision: 1.35 $"; char *rev="$Revision: 1.36 $";
Cctype.ob_type=&PyType_Type; Cctype.ob_type=&PyType_Type;
...@@ -742,6 +742,11 @@ initcPickleCache(void) ...@@ -742,6 +742,11 @@ initcPickleCache(void)
py__p_jar=PyString_FromString("_p_jar"); py__p_jar=PyString_FromString("_p_jar");
py__p_changed=PyString_FromString("_p_changed"); py__p_changed=PyString_FromString("_p_changed");
PyDict_SetItemString(d,"__version__", s = PyString_FromStringAndSize(rev+11,strlen(rev+11)-2);
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 cPickleCache");
} }
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
static char cPickleCache_doc_string[] = static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n" "Defines the PickleCache used by ZODB Connection objects.\n"
"\n" "\n"
"$Id: cPickleCache.c,v 1.35 2001/11/06 19:37:00 jeremy Exp $\n"; "$Id: cPickleCache.c,v 1.36 2001/11/08 17:13:01 bwarsaw Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;} #define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E)) #define UNLESS(E) if(!(E))
...@@ -726,8 +726,8 @@ static struct PyMethodDef cCM_methods[] = { ...@@ -726,8 +726,8 @@ static struct PyMethodDef cCM_methods[] = {
void void
initcPickleCache(void) initcPickleCache(void)
{ {
PyObject *m, *d; PyObject *m, *d, *s;
char *rev="$Revision: 1.35 $"; char *rev="$Revision: 1.36 $";
Cctype.ob_type=&PyType_Type; Cctype.ob_type=&PyType_Type;
...@@ -742,6 +742,11 @@ initcPickleCache(void) ...@@ -742,6 +742,11 @@ initcPickleCache(void)
py__p_jar=PyString_FromString("_p_jar"); py__p_jar=PyString_FromString("_p_jar");
py__p_changed=PyString_FromString("_p_changed"); py__p_changed=PyString_FromString("_p_changed");
PyDict_SetItemString(d,"__version__", s = PyString_FromStringAndSize(rev+11,strlen(rev+11)-2);
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 cPickleCache");
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment