From 74c1040dbc4b4977045745f924ea0774c2e3ee53 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 24 Sep 2009 12:52:32 +0300 Subject: [PATCH] Call (sub)type tp_free from destructors - more preliminaries for subtyping - remove pointless NULL checks --- python/header-py.c | 2 +- python/rpmds-py.c | 6 ++---- python/rpmfi-py.c | 6 ++---- python/rpmmi-py.c | 8 +++----- python/rpmps-py.c | 6 ++---- python/rpmts-py.c | 2 +- python/spec-py.c | 8 ++++---- 7 files changed, 15 insertions(+), 23 deletions(-) diff --git a/python/header-py.c b/python/header-py.c index 29a2f7e..9bd05c0 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -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) diff --git a/python/rpmds-py.c b/python/rpmds-py.c index dccd9a7..5ac4dda 100644 --- a/python/rpmds-py.c +++ b/python/rpmds-py.c @@ -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 diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c index 9a27e04..860e069 100644 --- a/python/rpmfi-py.c +++ b/python/rpmfi-py.c @@ -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 diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index 0fa1ab3..d6ab095 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -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[] = diff --git a/python/rpmps-py.c b/python/rpmps-py.c index 82422c0..c9f6050 100644 --- a/python/rpmps-py.c +++ b/python/rpmps-py.c @@ -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 diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 2ade492..821d951 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -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) diff --git a/python/spec-py.c b/python/spec-py.c index d4d13b3..85f2d10 100644 --- a/python/spec-py.c +++ b/python/spec-py.c @@ -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) -- 2.7.4