summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-05-26 09:22:17 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-05-26 09:22:17 +0300
commit775f4217560ac2d136b5c53b6c691771af058244 (patch)
tree62b63502b38cae875654372335e4ad380012bbdd /python
parent276994ca46697f5660ff92a3b4329b2bc3c83eb6 (diff)
downloadlibrpm-tizen-775f4217560ac2d136b5c53b6c691771af058244.tar.gz
librpm-tizen-775f4217560ac2d136b5c53b6c691771af058244.tar.bz2
librpm-tizen-775f4217560ac2d136b5c53b6c691771af058244.zip
Convert python rpmMergeHeaders to new interfaces
Diffstat (limited to 'python')
-rw-r--r--python/header-py.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/python/header-py.c b/python/header-py.c
index d40968382..449d9b428 100644
--- a/python/header-py.c
+++ b/python/header-py.c
@@ -689,44 +689,44 @@ int rpmMergeHeaders(PyObject * list, FD_t fd, int matchTag)
{
Header h;
HeaderIterator hi;
- int32_t * newMatch;
- int32_t * oldMatch;
+ rpmTag newMatch, oldMatch;
hdrObject * hdr;
- rpm_count_t c, count = 0;
- rpmTag tag;
- rpmTagType type;
- void * p;
+ rpm_count_t count = 0;
+ int rc = 1; /* assume failure */
+ rpmtd td = rpmtdNew();
Py_BEGIN_ALLOW_THREADS
h = headerRead(fd, HEADER_MAGIC_YES);
Py_END_ALLOW_THREADS
while (h) {
- if (!headerGetEntry(h, matchTag, NULL, (void **) &newMatch, NULL)) {
+ if (!headerGet(h, matchTag, td, HEADERGET_MINMEM)) {
PyErr_SetString(pyrpmError, "match tag missing in new header");
- return 1;
+ goto exit;
}
+ newMatch = rpmtdTag(td);
+ rpmtdFreeData(td);
hdr = (hdrObject *) PyList_GetItem(list, count++);
- if (!hdr) return 1;
+ if (!hdr) goto exit;
- if (!headerGetEntry(hdr->h, matchTag, NULL, (void **) &oldMatch, NULL)) {
+ if (!headerGet(hdr->h, matchTag, td, HEADERGET_MINMEM)) {
PyErr_SetString(pyrpmError, "match tag missing in new header");
- return 1;
+ goto exit;
}
+ oldMatch = rpmtdTag(td);
+ rpmtdFreeData(td);
- if (*newMatch != *oldMatch) {
+ if (newMatch != oldMatch) {
PyErr_SetString(pyrpmError, "match tag mismatch");
- return 1;
+ goto exit;
}
- for (hi = headerInitIterator(h);
- headerNextIterator(hi, &tag, &type, (void *) &p, &c);
- p = headerFreeData(p, type))
+ for (hi = headerInitIterator(h); headerNext(hi, td); rpmtdFreeData(td))
{
/* could be dupes */
- headerRemoveEntry(hdr->h, tag);
- headerAddEntry(hdr->h, tag, type, p, c);
+ headerRemoveEntry(hdr->h, rpmtdTag(td));
+ headerPut(hdr->h, td, HEADERPUT_DEFAULT);
}
headerFreeIterator(hi);
@@ -736,8 +736,11 @@ int rpmMergeHeaders(PyObject * list, FD_t fd, int matchTag)
h = headerRead(fd, HEADER_MAGIC_YES);
Py_END_ALLOW_THREADS
}
+ rc = 0;
- return 0;
+exit:
+ rpmtdFree(td);
+ return rc;
}
PyObject *