Call (sub)type tp_free from destructors
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 24 Sep 2009 09:52:32 +0000 (12:52 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 24 Sep 2009 09:52:32 +0000 (12:52 +0300)
- more preliminaries for subtyping
- remove pointless NULL checks

python/header-py.c
python/rpmds-py.c
python/rpmfi-py.c
python/rpmmi-py.c
python/rpmps-py.c
python/rpmts-py.c
python/spec-py.c

index 29a2f7e..9bd05c0 100644 (file)
@@ -402,7 +402,7 @@ static PyObject *hdr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
 static void hdr_dealloc(hdrObject * s)
 {
     if (s->h) headerFree(s->h);
-    PyObject_Del(s);
+    s->ob_type->tp_free((PyObject *)s);
 }
 
 int tagNumFromPyObject (PyObject *item, rpmTag *tagp)
index dccd9a7..5ac4dda 100644 (file)
@@ -379,10 +379,8 @@ The current index in ds is positioned at overlapping member upon success.\n" },
 static void
 rpmds_dealloc(rpmdsObject * s)
 {
-    if (s) {
-       s->ds = rpmdsFree(s->ds);
-       PyObject_Del(s);
-    }
+    s->ds = rpmdsFree(s->ds);
+    s->ob_type->tp_free((PyObject *)s);
 }
 
 static int
index 9a27e04..860e069 100644 (file)
@@ -257,10 +257,8 @@ static struct PyMethodDef rpmfi_methods[] = {
 static void
 rpmfi_dealloc(rpmfiObject * s)
 {
-    if (s) {
-       s->fi = rpmfiFree(s->fi);
-       PyObject_Del(s);
-    }
+    s->fi = rpmfiFree(s->fi);
+    s->ob_type->tp_free((PyObject *)s);
 }
 
 static int
index 0fa1ab3..d6ab095 100644 (file)
@@ -131,11 +131,9 @@ static struct PyMethodDef rpmmi_methods[] = {
 
 static void rpmmi_dealloc(rpmmiObject * s)
 {
-    if (s) {
-       s->mi = rpmdbFreeIterator(s->mi);
-       Py_DECREF(s->ref);
-       PyObject_Del(s);
-    }
+    s->mi = rpmdbFreeIterator(s->mi);
+    Py_DECREF(s->ref);
+    s->ob_type->tp_free((PyObject *)s);
 }
 
 static char rpmmi_doc[] =
index 82422c0..c9f6050 100644 (file)
@@ -61,10 +61,8 @@ static struct PyMethodDef rpmps_methods[] = {
 static void
 rpmps_dealloc(rpmpsObject * s)
 {
-    if (s) {
-       s->ps = rpmpsFree(s->ps);
-       PyObject_Del(s);
-    }
+    s->ps = rpmpsFree(s->ps);
+    s->ob_type->tp_free((PyObject *)s);
 }
 
 static int
index 2ade492..821d951 100644 (file)
@@ -982,7 +982,7 @@ static void rpmts_dealloc(rpmtsObject * s)
     /* 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);
+    s->ob_type->tp_free((PyObject *)s);
 }
 
 static PyObject * rpmts_getattro(PyObject * o, PyObject * n)
index d4d13b3..85f2d10 100644 (file)
@@ -37,10 +37,10 @@ struct specObject_s {
 static void 
 spec_dealloc(specObject * s) 
 {
-        if (s->spec) {
-            s->spec=freeSpec(s->spec);
-        }
-        PyObject_Del(s);
+    if (s->spec) {
+       s->spec=freeSpec(s->spec);
+    }
+    s->ob_type->tp_free((PyObject *)s);
 }
 
 /* XXX TODO return something sensible if spec exists but component (eg %clean)