diff options
-rw-r--r-- | python/header-py.c | 2 | ||||
-rw-r--r-- | python/rpmds-py.c | 9 | ||||
-rw-r--r-- | python/rpmfi-py.c | 10 | ||||
-rw-r--r-- | python/rpmmi-py.c | 5 | ||||
-rw-r--r-- | python/rpmps-py.c | 16 | ||||
-rw-r--r-- | python/rpmte-py.c | 4 | ||||
-rw-r--r-- | python/rpmts-py.c | 34 | ||||
-rw-r--r-- | python/rpmts-py.h | 2 | ||||
-rw-r--r-- | python/spec-py.c | 4 |
9 files changed, 39 insertions, 47 deletions
diff --git a/python/header-py.c b/python/header-py.c index 42a73a0be..f99cf5e48 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -546,6 +546,8 @@ PyTypeObject hdr_Type = { PyObject * hdr_Wrap(Header h) { hdrObject * hdr = PyObject_New(hdrObject, &hdr_Type); + if (hdr == NULL) return PyErr_NoMemory(); + hdr->h = headerLink(h); return (PyObject *) hdr; } diff --git a/python/rpmds-py.c b/python/rpmds-py.c index 25cd3e38c..0c3a45928 100644 --- a/python/rpmds-py.c +++ b/python/rpmds-py.c @@ -468,11 +468,11 @@ fprintf(stderr, "%p -- ds %p\n", s, s->ds); */ static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) { - rpmdsObject * s = (void *) PyObject_New(rpmdsObject, subtype); hdrObject * ho = NULL; PyObject * to = NULL; rpmTag tagN = RPMTAG_REQUIRENAME; rpmsenseFlags flags = 0; + rpmds ds = NULL; char * kwlist[] = {"header", "tag", "flags", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|Oi:rpmds_new", kwlist, @@ -483,9 +483,9 @@ static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kw tagN = tagNumFromPyObject(to); if (tagN == RPMTAG_NOT_FOUND) return NULL; } - s->ds = rpmdsNew(hdrGetHeader(ho), tagN, 0); + ds = rpmdsNew(hdrGetHeader(ho), tagN, 0); - return (PyObject *)s; + return rpmds_Wrap(ds); } /** @@ -549,9 +549,8 @@ rpmds dsFromDs(rpmdsObject * s) PyObject * rpmds_Wrap(rpmds ds) { rpmdsObject * s = PyObject_New(rpmdsObject, &rpmds_Type); + if (s == NULL) return PyErr_NoMemory(); - if (s == NULL) - return NULL; s->ds = ds; s->active = 0; return (PyObject *) s; diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c index 4665c4290..fbe7955b1 100644 --- a/python/rpmfi-py.c +++ b/python/rpmfi-py.c @@ -342,10 +342,9 @@ fprintf(stderr, "%p -- fi %p\n", s, s->fi); */ static PyObject * rpmfi_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) { - rpmfiObject * s = (void *) PyObject_New(rpmfiObject, subtype); - hdrObject * ho = NULL; PyObject * to = NULL; + rpmfi fi = NULL; rpmTag tagN = RPMTAG_BASENAMES; int flags = 0; char * kwlist[] = {"header", "tag", "flags", NULL}; @@ -358,9 +357,9 @@ static PyObject * rpmfi_new(PyTypeObject * subtype, PyObject *args, PyObject *kw tagN = tagNumFromPyObject(to); if (tagN == RPMTAG_NOT_FOUND) return NULL; } - s->fi = rpmfiNew(NULL, hdrGetHeader(ho), tagN, flags); + fi = rpmfiNew(NULL, hdrGetHeader(ho), tagN, flags); - return (PyObject *)s; + return rpmfi_Wrap(fi); } /** @@ -423,9 +422,8 @@ rpmfi fiFromFi(rpmfiObject * s) PyObject * rpmfi_Wrap(rpmfi fi) { rpmfiObject *s = PyObject_New(rpmfiObject, &rpmfi_Type); + if (s == NULL) return PyErr_NoMemory(); - if (s == NULL) - return NULL; s->fi = fi; s->active = 0; return (PyObject *) s; diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index c1768d612..755a02960 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -214,11 +214,8 @@ PyTypeObject rpmmi_Type = { PyObject * rpmmi_Wrap(rpmdbMatchIterator mi, PyObject *s) { rpmmiObject * mio = PyObject_New(rpmmiObject, &rpmmi_Type); + if (mio == NULL) return PyErr_NoMemory(); - if (mio == NULL) { - PyErr_SetString(pyrpmError, "out of memory creating rpmmiObject"); - return NULL; - } mio->mi = mi; mio->ref = s; Py_INCREF(mio->ref); diff --git a/python/rpmps-py.c b/python/rpmps-py.c index 408234ce2..652d83b6c 100644 --- a/python/rpmps-py.c +++ b/python/rpmps-py.c @@ -165,15 +165,8 @@ fprintf(stderr, "%p -- ps %p\n", s, s->ps); */ static PyObject * rpmps_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) { - rpmpsObject * s = (void *) PyObject_New(rpmpsObject, subtype); - - s->ps = rpmpsCreate(); - s->psi = NULL; - -if (_rpmps_debug) -fprintf(stderr, "%p ++ ps %p\n", s, s->ps); - - return (PyObject *)s; + rpmps ps = rpmpsCreate(); + return rpmps_Wrap(ps); } /** @@ -236,10 +229,9 @@ rpmps psFromPs(rpmpsObject * s) PyObject * rpmps_Wrap(rpmps ps) { rpmpsObject * s = PyObject_New(rpmpsObject, &rpmps_Type); + if (s == NULL) return PyErr_NoMemory(); - if (s == NULL) - return NULL; - s->ps = ps; + s->ps = ps; /* XXX refcounts? */ s->psi = NULL; return (PyObject *) s; } diff --git a/python/rpmte-py.c b/python/rpmte-py.c index e59a275eb..54a9dfaa3 100644 --- a/python/rpmte-py.c +++ b/python/rpmte-py.c @@ -349,8 +349,8 @@ PyTypeObject rpmte_Type = { PyObject * rpmte_Wrap(rpmte te) { rpmteObject *s = PyObject_New(rpmteObject, &rpmte_Type); - if (s == NULL) - return NULL; + if (s == NULL) return PyErr_NoMemory(); + s->te = te; return (PyObject *) s; } diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 3dd77b4d5..704d5f35c 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -1238,34 +1238,23 @@ fprintf(stderr, "%p -- ts %p db %p\n", s, s->ts, rpmtsGetRdb(s->ts)); */ static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) { - rpmtsObject * s = (void *) PyObject_New(rpmtsObject, subtype); - char * rootDir = "/"; rpmVSFlags vsflags = rpmExpandNumeric("%{?__vsflags}"); char * kwlist[] = {"rootdir", "vsflags", 0}; - - if (_rpmts_debug < 0) - fprintf(stderr, "*** rpmts_new(%p,%p,%p)\n", s, args, kwds); + rpmts ts = NULL; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|si:rpmts_new", kwlist, &rootDir, &vsflags)) return NULL; - s->ts = rpmtsCreate(); + ts = rpmtsCreate(); /* XXX: Why is there no rpmts_SetRootDir() ? */ - (void) rpmtsSetRootDir(s->ts, rootDir); + (void) rpmtsSetRootDir(ts, rootDir); /* XXX: make this use common code with rpmts_SetVSFlags() to check the * python objects */ - (void) rpmtsSetVSFlags(s->ts, vsflags); - s->keyList = PyList_New(0); - s->scriptFd = NULL; - s->tsi = NULL; - s->tsiFilter = 0; + (void) rpmtsSetVSFlags(ts, vsflags); - if (_rpmts_debug) - fprintf(stderr, "%p ++ ts %p db %p\n", s, s->ts, rpmtsGetRdb(s->ts)); - - return (PyObject *)s; + return rpmts_Wrap(ts); } /** @@ -1326,3 +1315,16 @@ rpmts_Create(PyObject * self, PyObject * args, PyObject * kwds) { return PyObject_Call((PyObject *) &rpmts_Type, args, kwds); } + +PyObject * rpmts_Wrap(rpmts ts) +{ + rpmtsObject * s = PyObject_New(rpmtsObject, &rpmts_Type); + if (s == NULL) return PyErr_NoMemory(); + + s->ts = ts; + s->keyList = PyList_New(0); + s->scriptFd = NULL; + s->tsi = NULL; + s->tsiFilter = 0; + return (PyObject *) s; +} diff --git a/python/rpmts-py.h b/python/rpmts-py.h index 212080f04..9fae1e1e9 100644 --- a/python/rpmts-py.h +++ b/python/rpmts-py.h @@ -17,6 +17,8 @@ enum { RPMDEP_SENSE_CONFLICTS /*!< conflict was found. */ }; +PyObject * rpmts_Wrap(rpmts ts); + PyObject * rpmts_Create(PyObject * s, PyObject * args, PyObject * kwds); #endif diff --git a/python/spec-py.c b/python/spec-py.c index 29f6e351a..e3614cee0 100644 --- a/python/spec-py.c +++ b/python/spec-py.c @@ -208,8 +208,8 @@ PyObject * spec_Wrap(rpmSpec spec) { specObject * s = PyObject_New(specObject, &spec_Type); - if (s == NULL) - return NULL; + if (s == NULL) return PyErr_NoMemory(); + s->spec = spec; return (PyObject *) s; } |