diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-07-01 13:37:48 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-07-01 13:37:48 +0300 |
commit | 7214b2e0a271b7a7b3df312c58593878cbf56504 (patch) | |
tree | e4e8033036d7d2a59f294078e9fb7b1bd2b9a163 /python | |
parent | dc50fb2863c81159fb4cc8b25ce3862720c0cce5 (diff) | |
download | librpm-tizen-7214b2e0a271b7a7b3df312c58593878cbf56504.tar.gz librpm-tizen-7214b2e0a271b7a7b3df312c58593878cbf56504.tar.bz2 librpm-tizen-7214b2e0a271b7a7b3df312c58593878cbf56504.zip |
Fix/sanitize rpm.fi python object creation a bit
- Move all actual initialization work into tp_init, permit
reinitialization without leaking and use PyType_GenericNew for
tp_new, eliminate internal rpmfi_Wrap() use.
There's one user for rpmfi_Wrap() in rpmte-py.c which needs fixing
later...
- Remove unused fiFromFi() helper function
Diffstat (limited to 'python')
-rw-r--r-- | python/rpmfi-py.c | 27 | ||||
-rw-r--r-- | python/rpmfi-py.h | 2 |
2 files changed, 7 insertions, 22 deletions
diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c index a43fee323..7dcf25d0e 100644 --- a/python/rpmfi-py.c +++ b/python/rpmfi-py.c @@ -288,26 +288,20 @@ static PyMappingMethods rpmfi_as_mapping = { static int rpmfi_init(rpmfiObject * s, PyObject *args, PyObject *kwds) { - s->active = 0; - return 0; -} - -static PyObject * rpmfi_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) -{ - PyObject * to = NULL; + PyObject * to = NULL; /* unused */ Header h = NULL; - rpmfi fi = NULL; - rpmTagVal tagN = RPMTAG_BASENAMES; int flags = 0; char * kwlist[] = {"header", "tag", "flags", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&|Oi:rpmfi_init", kwlist, hdrFromPyObject, &h, &to, &flags)) - return NULL; + return -1; - fi = rpmfiNew(NULL, h, tagN, flags); + rpmfiFree(s->fi); + s->fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, flags); + s->active = 0; - return rpmfi_Wrap(subtype, fi); + return 0; } static char rpmfi_doc[] = @@ -352,18 +346,11 @@ PyTypeObject rpmfi_Type = { 0, /* tp_dictoffset */ (initproc) rpmfi_init, /* tp_init */ 0, /* tp_alloc */ - (newfunc) rpmfi_new, /* tp_new */ + PyType_GenericNew, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; -/* ---------- */ - -rpmfi fiFromFi(rpmfiObject * s) -{ - return s->fi; -} - PyObject * rpmfi_Wrap(PyTypeObject *subtype, rpmfi fi) { rpmfiObject *s = (rpmfiObject *)subtype->tp_alloc(subtype, 0); diff --git a/python/rpmfi-py.h b/python/rpmfi-py.h index 604bf716d..bf7d05b13 100644 --- a/python/rpmfi-py.h +++ b/python/rpmfi-py.h @@ -9,8 +9,6 @@ extern PyTypeObject rpmfi_Type; #define rpmfiObject_Check(v) ((v)->ob_type == &rpmfi_Type) -rpmfi fiFromFi(rpmfiObject * fi); - PyObject * rpmfi_Wrap(PyTypeObject *subtype, rpmfi fi); #endif |