]> granicus.if.org Git - python/commitdiff
#Plug small memory leaks in constructors.
authorGuido van Rossum <guido@python.org>
Wed, 3 Sep 1997 18:19:40 +0000 (18:19 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 3 Sep 1997 18:19:40 +0000 (18:19 +0000)
Modules/cPickle.c
Modules/cStringIO.c
Modules/operator.c

index 980fb286c4ef8008606009fa7967b9694f6c1f9c..b5fddd0e7ebc985bb03b28d362f2927b448ad846 100644 (file)
@@ -3876,7 +3876,7 @@ init_stuff(PyObject *module, PyObject *module_dict) {
 /* Initialization function for the module (*must* be called initcPickle) */
 void
 initcPickle() {
-    PyObject *m, *d;
+    PyObject *m, *d, *v;
     char *rev="$Revision$";
     PyObject *format_version;
     PyObject *compatible_formats;
@@ -3893,7 +3893,8 @@ initcPickle() {
     /* Add some symbolic constants to the module */
     d = PyModule_GetDict(m);
     PyDict_SetItemString(d,"__version__",
-                        PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));
+                    v = PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));
+    Py_XDECREF(v);
 
 #ifdef FORMAT_1_3
     format_version = PyString_FromString("1.3");
@@ -3905,6 +3906,8 @@ initcPickle() {
 
     PyDict_SetItemString(d, "format_version", format_version);
     PyDict_SetItemString(d, "compatible_formats", compatible_formats);
+    Py_XDECREF(format_version);
+    Py_XDECREF(compatible_formats);
 
     init_stuff(m, d);
     CHECK_FOR_ERRORS("can't initialize module cPickle");
index b08c899cf0e8c78de87d94b15c33a382b6f4a1fe..ff47b7005a7f380cb7c442b5ded0bbcdc6e8d054 100644 (file)
@@ -600,7 +600,7 @@ static struct PycStringIO_CAPI CAPI = {
 
 void
 initcStringIO() {
-  PyObject *m, *d;
+  PyObject *m, *d, *v;
 
 
   /* Create the module and add the functions */
@@ -614,7 +614,9 @@ initcStringIO() {
   /* Export C API */
   Itype.ob_type=&PyType_Type;
   Otype.ob_type=&PyType_Type;
-  PyDict_SetItemString(d,"cStringIO_CAPI", PyCObject_FromVoidPtr(&CAPI,NULL));
+  PyDict_SetItemString(d,"cStringIO_CAPI",
+                      v = PyCObject_FromVoidPtr(&CAPI,NULL));
+  Py_XDECREF(v);
 
   /* Export Types */
   PyDict_SetItemString(d,"InputType",  (PyObject*)&Itype);
@@ -631,6 +633,9 @@ initcStringIO() {
 /******************************************************************************
 
   $Log$
+  Revision 2.8  1997/09/03 18:19:38  guido
+  #Plug small memory leaks in constructors.
+
   Revision 2.7  1997/09/03 00:09:26  guido
   Fix the bug Jeremy was experiencing: both the close() and the
   dealloc() functions contained code to free/DECREF the buffer
index 43324a29c86861097c851e801c884a020d196169..14a7aaf12fb1ab6a0bbdbfc54e385d86b9505fdb 100644 (file)
@@ -256,7 +256,7 @@ spam2(delslice,__delslice__,
 void
 initoperator()
 {
-        PyObject *m, *d;
+        PyObject *m, *d, *v;
   
         /* Create the module and add the functions */
         m = Py_InitModule4("operator", operator_methods,
@@ -266,7 +266,8 @@ initoperator()
         /* Add some symbolic constants to the module */
         d = PyModule_GetDict(m);
         PyDict_SetItemString(d, "__version__",
-                             PyString_FromString("$Rev$"));
+                             v = PyString_FromString("$Rev$"));
+       Py_XDECREF(v);
   
         /* Check for errors */
         if (PyErr_Occurred())