summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@971eb68f-4bfb-0310-8326-d2484c010a4c>2012-06-12 17:37:25 +0000
committertv <tv@971eb68f-4bfb-0310-8326-d2484c010a4c>2012-06-12 17:37:25 +0000
commitebd302e013c8c79d677a55d71a8df59ab46e4568 (patch)
tree632561038443b41fe3151a636afeb6cdbcd715f7
parentbae8df3a4971bfdacc5096eb9a8d2ca4bef27c72 (diff)
downloadperl-RPM4-ebd302e013c8c79d677a55d71a8df59ab46e4568.tar
perl-RPM4-ebd302e013c8c79d677a55d71a8df59ab46e4568.tar.gz
perl-RPM4-ebd302e013c8c79d677a55d71a8df59ab46e4568.tar.bz2
perl-RPM4-ebd302e013c8c79d677a55d71a8df59ab46e4568.tar.xz
perl-RPM4-ebd302e013c8c79d677a55d71a8df59ab46e4568.zip
(_headername_vs_dep,Header_fullname,Header_tagtype) adapt to rpm 4.6 changes: headerGetEntry -> headerGet
(using previously introduced wrappers) git-svn-id: svn+ssh://haiku.zarb.org/home/projects/rpm4/svn/trunk@189 971eb68f-4bfb-0310-8326-d2484c010a4c
-rw-r--r--RPM4/NEWS3
-rw-r--r--RPM4/src/RPM4.xs62
2 files changed, 36 insertions, 29 deletions
diff --git a/RPM4/NEWS b/RPM4/NEWS
index 25ef0a5..0c55c60 100644
--- a/RPM4/NEWS
+++ b/RPM4/NEWS
@@ -1,3 +1,6 @@
+- use rpm-4.6+ API, not rpm-4.4 compatibility one
+ (fix some memleaks btw)
+
Version 0.28 - 9 June 2012
- fix build with rpm-4.10.0
diff --git a/RPM4/src/RPM4.xs b/RPM4/src/RPM4.xs
index 285f54f..6972587 100644
--- a/RPM4/src/RPM4.xs
+++ b/RPM4/src/RPM4.xs
@@ -493,12 +493,15 @@ int _headername_vs_dep(Header h, rpmds dep, int nopromote) {
char *name; rpm_tagtype_t type;
int rc = 0;
CHECK_RPMDS_IX(dep);
- headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, NULL);
+ struct rpmtd_s val;
+
+ headerGet(h, RPMTAG_NAME, &val, HEADERGET_MINMEM);
+ name = (char *) rpmtdGetString(&val);
if (strcmp(name, rpmdsN(dep)) != 0)
rc = 0;
else
rc = rpmdsNVRMatchesDep(h, dep, nopromote);
- headerFreeData(name, type);
+ rpmtdFreeData(&val);
return rc;
/* return 1 if match */
}
@@ -1110,9 +1113,6 @@ Header_tag(h, sv_tag)
Header h
SV * sv_tag
PREINIT:
- void *ret = NULL;
- rpm_tagtype_t type;
- rpm_tagtype_t n;
rpmTag tag = -1;
PPCODE:
if (SvIOK(sv_tag)) {
@@ -1120,24 +1120,29 @@ Header_tag(h, sv_tag)
} else if (SvPOK(sv_tag)) {
tag = tagValue(SvPV_nolen(sv_tag));
}
- if (tag > 0)
- if (headerGetEntry(h, tag, &type, &ret, &n)) {
+ if (tag > 0) {
+ struct rpmtd_s val;
+ if (headerGet(h, tag, &val, HEADERGET_DEFAULT)) {
+ int type = val.type;
+ int n = rpmtdCount(&val);
+
switch(type) {
case RPM_STRING_ARRAY_TYPE:
{
int i;
- char **s;
EXTEND(SP, n);
- s = (char **)ret;
+ rpmtdInit(&val);
for (i = 0; i < n; i++) {
- PUSHs(sv_2mortal(newSVpv(s[i], 0)));
+ PUSHs(sv_2mortal(newSVpv(rpmtdNextString(&val), 0)));
}
}
break;
- case RPM_STRING_TYPE:
- PUSHs(sv_2mortal(newSVpv((char *)ret, 0)));
+ case RPM_STRING_TYPE: {
+ char *name = (char *) rpmtdGetString(&val);
+ PUSHs(sv_2mortal(newSVpv(name, 0)));
+ };
break;
case RPM_CHAR_TYPE:
case RPM_INT8_TYPE:
@@ -1145,32 +1150,34 @@ Header_tag(h, sv_tag)
case RPM_INT32_TYPE:
{
int i;
- int *r;
EXTEND(SP, n);
- r = (int *)ret;
+ rpmtdInit(&val);
for (i = 0; i < n; i++) {
- PUSHs(sv_2mortal(newSViv(r[i])));
+ rpmtdNext(&val);
+ PUSHs(sv_2mortal(newSViv(rpmtdGetNumber(&val))));
}
}
break;
case RPM_BIN_TYPE:
- PUSHs(sv_2mortal(newSVpv((char *)ret, n)));
+ /* XXX HACK ALERT: element field abused as no. bytes of binary data. */
+ PUSHs(sv_2mortal(newSVpv((char *)val.data, val.count)));
break;
default:
croak("unknown rpm tag type %d", type);
}
+ rpmtdFreeData(&val);
}
- headerFreeTag(h, ret, type);
+ }
unsigned int
Header_tagtype(h, sv_tag)
Header h
SV * sv_tag
PREINIT:
- rpm_tagtype_t type;
rpmTag tag = -1;
+ struct rpmtd_s td;
CODE:
if (SvIOK(sv_tag)) {
tag = SvIV(sv_tag);
@@ -1179,8 +1186,9 @@ Header_tagtype(h, sv_tag)
}
RETVAL = RPM_NULL_TYPE;
if (tag > 0)
- if (headerGetEntry(h, tag, &type, NULL, NULL))
- RETVAL = type;
+ if (headerGet(h, tag, &td, HEADERGET_DEFAULT))
+ RETVAL = td.type;
+ rpmtdFreeData(&td);
OUTPUT:
RETVAL
@@ -1207,11 +1215,11 @@ Header_fullname(h)
char *arch;
PPCODE:
if (h) {
- headerGetEntry(h, RPMTAG_NAME, NULL, (void *) &name, NULL);
- headerGetEntry(h, RPMTAG_VERSION, NULL, (void *) &version, NULL);
- headerGetEntry(h, RPMTAG_RELEASE, NULL, (void *) &release, NULL);
- headerGetEntry(h, RPMTAG_ARCH, NULL, (void *) &arch, NULL);
-
+ name = get_name(h, RPMTAG_NAME);
+ version = get_name(h, RPMTAG_VERSION);
+ release = get_name(h, RPMTAG_RELEASE);
+ arch = get_arch(h);
+
if (gimme == G_SCALAR) {
XPUSHs(sv_2mortal(newSVpvf("%s-%s-%s.%s",
name,
@@ -1231,10 +1239,6 @@ Header_fullname(h)
}
}
}
- headerFreeTag(h, name, RPM_STRING_TYPE);
- headerFreeTag(h, version, RPM_STRING_TYPE);
- headerFreeTag(h, release, RPM_STRING_TYPE);
- headerFreeTag(h, arch, RPM_STRING_TYPE);
void
Header_nevr(header)