Commit 469b47a0 authored by Jeremy Hylton's avatar Jeremy Hylton

(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.
parent ff24f9df
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
static char cPersistence_doc_string[] = static char cPersistence_doc_string[] =
"Defines Persistent mixin class for persistent objects.\n" "Defines Persistent mixin class for persistent objects.\n"
"\n" "\n"
"$Id: cPersistence.c,v 1.49 2002/02/11 23:40:42 gvanrossum Exp $\n"; "$Id: cPersistence.c,v 1.50 2002/03/08 18:36:13 jeremy Exp $\n";
#include <string.h> #include <string.h>
#include "cPersistence.h" #include "cPersistence.h"
...@@ -336,7 +336,7 @@ Per_dealloc(cPersistentObject *self) ...@@ -336,7 +336,7 @@ Per_dealloc(cPersistentObject *self)
Py_XDECREF(self->jar); Py_XDECREF(self->jar);
Py_XDECREF(self->oid); Py_XDECREF(self->oid);
Py_DECREF(self->ob_type); Py_DECREF(self->ob_type);
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,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.40 2002/02/11 23:40:42 gvanrossum Exp $\n"; "$Id: cPickleCache.c,v 1.41 2002/03/08 18:36:14 jeremy Exp $\n";
/* Compute the current time in the units and range used for peristent /* Compute the current time in the units and range used for peristent
objects. */ objects. */
...@@ -497,7 +497,7 @@ cc_dealloc(ccobject *self) ...@@ -497,7 +497,7 @@ cc_dealloc(ccobject *self)
Py_XDECREF(self->data); Py_XDECREF(self->data);
Py_XDECREF(self->jar); Py_XDECREF(self->jar);
Py_XDECREF(self->setklassstate); Py_XDECREF(self->setklassstate);
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
static char TimeStamp_module_documentation[] = static char TimeStamp_module_documentation[] =
"Defines 64-bit TimeStamp objects used as ZODB serial numbers.\n" "Defines 64-bit TimeStamp objects used as ZODB serial numbers.\n"
"\n" "\n"
"\n$Id: TimeStamp.c,v 1.14 2002/02/11 23:40:42 gvanrossum Exp $\n"; "\n$Id: TimeStamp.c,v 1.15 2002/03/08 18:36:13 jeremy Exp $\n";
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
...@@ -318,7 +318,7 @@ TimeStamp_dealloc(TimeStamp *self) ...@@ -318,7 +318,7 @@ TimeStamp_dealloc(TimeStamp *self)
#ifdef USE_EXTENSION_CLASS #ifdef USE_EXTENSION_CLASS
Py_DECREF(self->ob_type); Py_DECREF(self->ob_type);
#endif #endif
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
static char cPersistence_doc_string[] = static char cPersistence_doc_string[] =
"Defines Persistent mixin class for persistent objects.\n" "Defines Persistent mixin class for persistent objects.\n"
"\n" "\n"
"$Id: cPersistence.c,v 1.49 2002/02/11 23:40:42 gvanrossum Exp $\n"; "$Id: cPersistence.c,v 1.50 2002/03/08 18:36:13 jeremy Exp $\n";
#include <string.h> #include <string.h>
#include "cPersistence.h" #include "cPersistence.h"
...@@ -336,7 +336,7 @@ Per_dealloc(cPersistentObject *self) ...@@ -336,7 +336,7 @@ Per_dealloc(cPersistentObject *self)
Py_XDECREF(self->jar); Py_XDECREF(self->jar);
Py_XDECREF(self->oid); Py_XDECREF(self->oid);
Py_DECREF(self->ob_type); Py_DECREF(self->ob_type);
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,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.40 2002/02/11 23:40:42 gvanrossum Exp $\n"; "$Id: cPickleCache.c,v 1.41 2002/03/08 18:36:14 jeremy Exp $\n";
/* Compute the current time in the units and range used for peristent /* Compute the current time in the units and range used for peristent
objects. */ objects. */
...@@ -497,7 +497,7 @@ cc_dealloc(ccobject *self) ...@@ -497,7 +497,7 @@ cc_dealloc(ccobject *self)
Py_XDECREF(self->data); Py_XDECREF(self->data);
Py_XDECREF(self->jar); Py_XDECREF(self->jar);
Py_XDECREF(self->setklassstate); Py_XDECREF(self->setklassstate);
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
static char coptimizations_doc_string[] = static char coptimizations_doc_string[] =
"C optimization for new_persistent_id().\n" "C optimization for new_persistent_id().\n"
"\n" "\n"
"$Id: coptimizations.c,v 1.16 2002/02/11 23:40:42 gvanrossum Exp $\n"; "$Id: coptimizations.c,v 1.17 2002/03/08 18:36:14 jeremy Exp $\n";
#include "Python.h" #include "Python.h"
#define DONT_USE_CPERSISTENCECAPI #define DONT_USE_CPERSISTENCECAPI
...@@ -61,7 +61,7 @@ persistent_id_dealloc(persistent_id *self) ...@@ -61,7 +61,7 @@ persistent_id_dealloc(persistent_id *self)
Py_DECREF(self->jar); Py_DECREF(self->jar);
Py_DECREF(self->stackup); Py_DECREF(self->stackup);
Py_XDECREF(self->new_oid); Py_XDECREF(self->new_oid);
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
static char cPersistence_doc_string[] = static char cPersistence_doc_string[] =
"Defines Persistent mixin class for persistent objects.\n" "Defines Persistent mixin class for persistent objects.\n"
"\n" "\n"
"$Id: cPersistence.c,v 1.49 2002/02/11 23:40:42 gvanrossum Exp $\n"; "$Id: cPersistence.c,v 1.50 2002/03/08 18:36:13 jeremy Exp $\n";
#include <string.h> #include <string.h>
#include "cPersistence.h" #include "cPersistence.h"
...@@ -336,7 +336,7 @@ Per_dealloc(cPersistentObject *self) ...@@ -336,7 +336,7 @@ Per_dealloc(cPersistentObject *self)
Py_XDECREF(self->jar); Py_XDECREF(self->jar);
Py_XDECREF(self->oid); Py_XDECREF(self->oid);
Py_DECREF(self->ob_type); Py_DECREF(self->ob_type);
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,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.40 2002/02/11 23:40:42 gvanrossum Exp $\n"; "$Id: cPickleCache.c,v 1.41 2002/03/08 18:36:14 jeremy Exp $\n";
/* Compute the current time in the units and range used for peristent /* Compute the current time in the units and range used for peristent
objects. */ objects. */
...@@ -497,7 +497,7 @@ cc_dealloc(ccobject *self) ...@@ -497,7 +497,7 @@ cc_dealloc(ccobject *self)
Py_XDECREF(self->data); Py_XDECREF(self->data);
Py_XDECREF(self->jar); Py_XDECREF(self->jar);
Py_XDECREF(self->setklassstate); Py_XDECREF(self->setklassstate);
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
......
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