Eliminate all custom tp_free() type methods
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 24 Sep 2009 10:40:44 +0000 (13:40 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 24 Sep 2009 10:40:44 +0000 (13:40 +0300)
- 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()

python/rpmds-py.c
python/rpmfi-py.c
python/rpmps-py.c
python/rpmts-py.c

index 5ac4dda..8750dda 100644 (file)
@@ -416,13 +416,6 @@ static int rpmds_init(rpmdsObject * s, PyObject *args, PyObject *kwds)
     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)
 {
     hdrObject * ho = NULL;
@@ -485,7 +478,7 @@ PyTypeObject rpmds_Type = {
        (initproc) rpmds_init,          /* tp_init */
        0,                              /* tp_alloc */
        (newfunc) rpmds_new,            /* tp_new */
-       (freefunc) rpmds_free,          /* tp_free */
+       0,                              /* tp_free */
        0,                              /* tp_is_gc */
 };
 
index 860e069..3ce3e2d 100644 (file)
@@ -294,13 +294,6 @@ static int rpmfi_init(rpmfiObject * s, PyObject *args, PyObject *kwds)
     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)
 {
     hdrObject * ho = NULL;
@@ -363,7 +356,7 @@ PyTypeObject rpmfi_Type = {
        (initproc) rpmfi_init,          /* tp_init */
        0,                              /* tp_alloc */
        (newfunc) rpmfi_new,            /* tp_new */
-       (freefunc) rpmfi_free,          /* tp_free */
+       0,                              /* tp_free */
        0,                              /* tp_is_gc */
 };
 
index c9f6050..b343ee3 100644 (file)
@@ -107,13 +107,6 @@ static PyMappingMethods rpmps_as_mapping = {
         (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)
 {
     rpmps ps = rpmpsCreate();
@@ -164,7 +157,7 @@ PyTypeObject rpmps_Type = {
        0,                              /* tp_init */
        0,                              /* tp_alloc */
        (newfunc) rpmps_new,            /* tp_new */
-       (freefunc) rpmps_free,          /* tp_free */
+       0,                              /* tp_free */
        0,                              /* tp_is_gc */
 };
 
index cd5471c..3cb138f 100644 (file)
@@ -1013,20 +1013,6 @@ static int rpmts_setattro(PyObject * o, PyObject * n, PyObject * v)
     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)
 {
     char * rootDir = "/";
@@ -1091,7 +1077,7 @@ PyTypeObject rpmts_Type = {
        0,                              /* tp_init */
        0,                              /* tp_alloc */
        (newfunc) rpmts_new,            /* tp_new */
-       (freefunc) rpmts_free,          /* tp_free */
+       0,                              /* tp_free */
        0,                              /* tp_is_gc */
 };