Eliminate all custom tp_free() type methods

- tp_free()'s purpose is only to free up the memory used by the python
  object structure, cleaning up our own allocations belongs to tp_dealloc()
This commit is contained in:
Panu Matilainen 2009-09-24 13:40:44 +03:00
parent d5f5156bd0
commit df40d9b27b
4 changed files with 4 additions and 39 deletions

View File

@ -416,13 +416,6 @@ static int rpmds_init(rpmdsObject * s, PyObject *args, PyObject *kwds)
return 0; return 0;
} }
static void rpmds_free(rpmdsObject * s)
{
s->ds = rpmdsFree(s->ds);
PyObject_Del((PyObject *)s);
}
static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
{ {
hdrObject * ho = NULL; hdrObject * ho = NULL;
@ -485,7 +478,7 @@ PyTypeObject rpmds_Type = {
(initproc) rpmds_init, /* tp_init */ (initproc) rpmds_init, /* tp_init */
0, /* tp_alloc */ 0, /* tp_alloc */
(newfunc) rpmds_new, /* tp_new */ (newfunc) rpmds_new, /* tp_new */
(freefunc) rpmds_free, /* tp_free */ 0, /* tp_free */
0, /* tp_is_gc */ 0, /* tp_is_gc */
}; };

View File

@ -294,13 +294,6 @@ static int rpmfi_init(rpmfiObject * s, PyObject *args, PyObject *kwds)
return 0; return 0;
} }
static void rpmfi_free(rpmfiObject * s)
{
s->fi = rpmfiFree(s->fi);
PyObject_Del((PyObject *)s);
}
static PyObject * rpmfi_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) static PyObject * rpmfi_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
{ {
hdrObject * ho = NULL; hdrObject * ho = NULL;
@ -363,7 +356,7 @@ PyTypeObject rpmfi_Type = {
(initproc) rpmfi_init, /* tp_init */ (initproc) rpmfi_init, /* tp_init */
0, /* tp_alloc */ 0, /* tp_alloc */
(newfunc) rpmfi_new, /* tp_new */ (newfunc) rpmfi_new, /* tp_new */
(freefunc) rpmfi_free, /* tp_free */ 0, /* tp_free */
0, /* tp_is_gc */ 0, /* tp_is_gc */
}; };

View File

@ -107,13 +107,6 @@ static PyMappingMethods rpmps_as_mapping = {
(binaryfunc) rpmps_subscript, /* mp_subscript */ (binaryfunc) rpmps_subscript, /* mp_subscript */
}; };
static void rpmps_free(rpmpsObject * s)
{
s->ps = rpmpsFree(s->ps);
PyObject_Del((PyObject *)s);
}
static PyObject * rpmps_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) static PyObject * rpmps_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
{ {
rpmps ps = rpmpsCreate(); rpmps ps = rpmpsCreate();
@ -164,7 +157,7 @@ PyTypeObject rpmps_Type = {
0, /* tp_init */ 0, /* tp_init */
0, /* tp_alloc */ 0, /* tp_alloc */
(newfunc) rpmps_new, /* tp_new */ (newfunc) rpmps_new, /* tp_new */
(freefunc) rpmps_free, /* tp_free */ 0, /* tp_free */
0, /* tp_is_gc */ 0, /* tp_is_gc */
}; };

View File

@ -1013,20 +1013,6 @@ static int rpmts_setattro(PyObject * o, PyObject * n, PyObject * v)
return 0; return 0;
} }
static void rpmts_free(rpmtsObject * s)
{
s->ts = rpmtsFree(s->ts);
if (s->scriptFd)
Fclose(s->scriptFd);
/* this will free the keyList, and decrement the ref count of all
the items on the list as well :-) */
Py_DECREF(s->keyList);
PyObject_Del((PyObject *)s);
}
static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
{ {
char * rootDir = "/"; char * rootDir = "/";
@ -1091,7 +1077,7 @@ PyTypeObject rpmts_Type = {
0, /* tp_init */ 0, /* tp_init */
0, /* tp_alloc */ 0, /* tp_alloc */
(newfunc) rpmts_new, /* tp_new */ (newfunc) rpmts_new, /* tp_new */
(freefunc) rpmts_free, /* tp_free */ 0, /* tp_free */
0, /* tp_is_gc */ 0, /* tp_is_gc */
}; };