RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 13-Oct-2007 19:50:06
Branch: HEAD Handle: 2007101318500600
Modified files:
rpm CHANGES
rpm/lib rpmds.c rpmds.h
Log:
- rpmds.c: use headerGetExtension everywhere.
Summary:
Revision Changes Path
1.1684 +1 -0 rpm/CHANGES
2.69 +72 -80 rpm/lib/rpmds.c
2.59 +0 -1 rpm/lib/rpmds.h
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.1683 -r1.1684 CHANGES
--- rpm/CHANGES 13 Oct 2007 08:42:07 -0000 1.1683
+++ rpm/CHANGES 13 Oct 2007 17:50:06 -0000 1.1684
@@ -1,4 +1,5 @@
4.5 -> 5.0:
+ - jbj: rpmds.c: use headerGetExtension everywhere.
- jbj: eliminate rpmtsSetSig(), use pgpSetSig() instead.
- jbj: fix: trade a double free for a ~100b/header memleak.
- jbj: fprint.c: use headerGetExtension everywhere.
@@ .
patch -p0 <<'@@ .'
Index: rpm/lib/rpmds.c
============================================================================
$ cvs diff -u -r2.68 -r2.69 rpmds.c
--- rpm/lib/rpmds.c 11 Oct 2007 19:44:22 -0000 2.68
+++ rpm/lib/rpmds.c 13 Oct 2007 17:50:06 -0000 2.69
@@ -137,7 +137,6 @@
rpmds rpmdsFree(rpmds ds)
{
- HFD_t hfd = headerFreeData;
rpmTag tagEVR, tagF;
if (ds == NULL)
@@ -182,11 +181,9 @@
return NULL;
if (ds->Count > 0) {
- ds->N = hfd(ds->N, ds->Nt);
- ds->EVR = hfd(ds->EVR, ds->EVRt);
- /*@-evalorder@*/
- ds->Flags = (ds->h != NULL ? hfd(ds->Flags, ds->Ft) : _free(ds->Flags));
- /*@=evalorder@*/
+ ds->N = _free(ds->N);
+ ds->EVR = _free(ds->EVR);
+ ds->Flags = _free(ds->Flags);
ds->h = headerFree(ds->h);
}
@@ -237,16 +234,20 @@
rpmds rpmdsNew(Header h, rpmTag tagN, int flags)
{
- HFD_t hfd = headerFreeData;
int scareMem = (flags & 0x1);
- HGE_t hge =
- (scareMem ? (HGE_t) headerGetEntryMinMemory : (HGE_t) headerGetEntry);
+ HGE_t hge = (HGE_t)headerGetExtension;
+ int_32 he_t = 0;
+ hRET_t he_p = { .ptr = NULL };
+ int_32 he_c = 0;
+ HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
+ HE_t he = &he_s;
+
rpmTag tagEVR, tagF;
rpmds ds = NULL;
const char * Type;
const char ** N;
- rpmTagType Nt;
int_32 Count;
+ int xx;
assert(scareMem == 0); /* XXX always allocate memory */
if (tagN == RPMTAG_PROVIDENAME) {
@@ -286,42 +287,41 @@
} else
goto exit;
- if (hge(h, tagN, &Nt, &N, &Count)
- && N != NULL && Count > 0)
- {
- int xx;
-
+ he->tag = tagN;
+ xx = hge(h, he->tag, he->t, he->p, he->c);
+ N = he_p.argv;
+ Count = he_c;
+ if (xx && N != NULL && Count > 0) {
ds = xcalloc(1, sizeof(*ds));
ds->Type = Type;
- ds->h = (scareMem ? headerLink(h) : NULL);
+ ds->h = NULL;
ds->i = -1;
ds->DNEVR = NULL;
ds->tagN = tagN;
ds->N = N;
- ds->Nt = Nt;
ds->Count = Count;
ds->nopromote = _rpmds_nopromote;
- if (tagEVR > 0)
- xx = hge(h, tagEVR, &ds->EVRt, &ds->EVR, NULL);
- if (tagF > 0)
- xx = hge(h, tagF, &ds->Ft, &ds->Flags, NULL);
- if (!scareMem && ds->Flags != NULL)
- ds->Flags = memcpy(xmalloc(ds->Count * sizeof(*ds->Flags)),
- ds->Flags, ds->Count * sizeof(*ds->Flags));
- { rpmTag tagA = RPMTAG_ARCH;
- rpmTagType At;
- const char * A = NULL;
- if (tagA > 0)
- xx = hge(h, tagA, &At, &A, NULL);
- ds->A = (xx && A != NULL ? xstrdup(A) : NULL);
- }
- { rpmTag tagBT = RPMTAG_BUILDTIME;
- rpmTagType BTt;
- int_32 * BTp = NULL;
- if (tagBT > 0)
- xx = hge(h, tagBT, &BTt, &BTp, NULL);
- ds->BT = (xx && BTp != NULL && BTt == RPM_INT32_TYPE ? *BTp : 0);
+ if (tagEVR > 0) {
+ he->tag = tagEVR;
+ xx = hge(h, he->tag, he->t, he->p, he->c);
+ ds->EVR = he_p.argv;
+ }
+ if (tagF > 0) {
+ he->tag = tagF;
+ xx = hge(h, he->tag, he->t, he->p, he->c);
+ ds->Flags = he_p.i32p;
+ }
+ {
+ he->tag = RPMTAG_ARCH;
+ xx = hge(h, he->tag, he->t, he->p, he->c);
+ ds->A = he_p.str;
+ }
+ {
+ he->tag = RPMTAG_BUILDTIME;
+ xx = hge(h, he->tag, he->t, he->p, he->c);
+ ds->BT = (he_p.ui32p ? *he_p.ui32p : 0);
+ he_p.ptr = _free(he_p.ptr);
}
if (tagN == RPMTAG_DIRNAMES) {
@@ -357,13 +357,11 @@
}
av[Count] = NULL;
- N = ds->N = hfd(ds->N, ds->Nt);
- ds->N = rpmdsDupArgv(av, Count);
+ N = ds->N = _free(ds->N);
+ N = ds->N = rpmdsDupArgv(av, Count);
av = argvFree(av);
- ds->EVR = hfd(ds->EVR, ds->EVRt);
- /*@-evalorder@*/
- ds->Flags = (ds->h != NULL ? hfd(ds->Flags, ds->Ft) : _free(ds->Flags));
- /*@=evalorder@*/
+ ds->EVR = _free(ds->EVR);
+ ds->Flags = _free(ds->Flags);
}
/*@-modfilesys@*/
@@ -478,11 +476,16 @@
rpmds rpmdsThis(Header h, rpmTag tagN, int_32 Flags)
{
- HGE_t hge = (HGE_t) headerGetEntryMinMemory;
+ HGE_t hge = (HGE_t)headerGetExtension;
+ int_32 he_t = 0;
+ hRET_t he_p = { .ptr = NULL };
+ int_32 he_c = 0;
+ HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
+ HE_t he = &he_s;
rpmds ds = NULL;
const char * Type;
- const char * n, * v, * r;
- int_32 * ep;
+ const char * Name, * V, * R;
+ int_32 E;
const char ** N, ** EVR;
char * t;
int xx;
@@ -510,54 +513,48 @@
} else
goto exit;
+ he->tag = RPMTAG_EPOCH;
+ xx = hge(h, he->tag, he->t, he->p, he->c);
+ E = (he_p.i32p ? *he_p.i32p : 0);
+ he_p.ptr = _free(he_p.ptr);
+
/*@-mods@*/
- xx = headerNEVRA(h, &n, NULL, &v, &r, NULL);
+ xx = headerNEVRA(h, &Name, NULL, &V, &R, NULL);
/*@=mods@*/
- ep = NULL;
- xx = hge(h, RPMTAG_EPOCH, NULL, &ep, NULL);
- t = xmalloc(sizeof(*N) + strlen(n) + 1);
+ t = xmalloc(sizeof(*N) + strlen(Name) + 1);
N = (const char **) t;
t += sizeof(*N);
*t = '\0';
N[0] = t;
- t = stpcpy(t, n);
+ t = stpcpy(t, Name);
- t = xmalloc(sizeof(*EVR) +
- (ep ? 20 : 0) + strlen(v) + strlen(r) + sizeof("-"));
+ t = xmalloc(sizeof(*EVR) + 20 + strlen(V) + strlen(R) + sizeof("-"));
EVR = (const char **) t;
t += sizeof(*EVR);
*t = '\0';
EVR[0] = t;
- if (ep) {
- sprintf(t, "%d:", *ep);
- t += strlen(t);
- }
- t = stpcpy( stpcpy( stpcpy( t, v), "-"), r);
+ sprintf(t, "%d:", E);
+ t += strlen(t);
+ t = stpcpy( stpcpy( stpcpy( t, V), "-"), R);
ds = xcalloc(1, sizeof(*ds));
ds->Type = Type;
ds->tagN = tagN;
ds->Count = 1;
ds->N = N;
- ds->Nt = -1; /* XXX to insure that hfd will free */
ds->EVR = EVR;
- ds->EVRt = -1; /* XXX to insure that hfd will free */
ds->Flags = xmalloc(sizeof(*ds->Flags)); ds->Flags[0] = Flags;
- { rpmTag tagA = RPMTAG_ARCH;
- rpmTagType At;
- const char * A = NULL;
- if (tagA > 0)
- xx = hge(h, tagA, &At, &A, NULL);
- ds->A = (xx && A != NULL ? xstrdup(A) : NULL);
- }
- { rpmTag tagBT = RPMTAG_BUILDTIME;
- rpmTagType BTt;
- int_32 * BTp = NULL;
- if (tagBT > 0)
- xx = hge(h, tagBT, &BTt, &BTp, NULL);
- ds->BT = (xx && BTp != NULL && BTt == RPM_INT32_TYPE ? *BTp : 0);
- }
+
+ he->tag = RPMTAG_ARCH;
+ xx = hge(h, he->tag, he->t, he->p, he->c);
+ ds->A = he_p.str;
+
+ he->tag = RPMTAG_BUILDTIME;
+ xx = hge(h, he->tag, he->t, he->p, he->c);
+ ds->BT = (he_p.ui32p ? *he_p.ui32p : 0);
+ he_p.ptr = _free(he_p.ptr);
+
{ char pre[2];
pre[0] = ds->Type[0];
pre[1] = '\0';
@@ -608,9 +605,7 @@
ds->Count = 1;
/*@-assignexpose@*/
ds->N = xmalloc(sizeof(*ds->N)); ds->N[0] = N;
- ds->Nt = -1; /* XXX to insure that hfd will free */
ds->EVR = xmalloc(sizeof(*ds->EVR)); ds->EVR[0] = EVR;
- ds->EVRt = -1; /* XXX to insure that hfd will free */
/*@=assignexpose@*/
ds->Flags = xmalloc(sizeof(*ds->Flags)); ds->Flags[0] = Flags;
{ char t[2];
@@ -941,7 +936,6 @@
ds->N = (ds->h != NULL
? memcpy(xmalloc(nb), ods->N, nb)
: rpmdsDupArgv(ods->N, ods->Count) );
- ds->Nt = ods->Nt;
/* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */
assert(ods->EVR != NULL);
@@ -951,13 +945,11 @@
ds->EVR = (ds->h != NULL
? memcpy(xmalloc(nb), ods->EVR, nb)
: rpmdsDupArgv(ods->EVR, ods->Count) );
- ds->EVRt = ods->EVRt;
nb = (ds->Count * sizeof(*ds->Flags));
ds->Flags = (ds->h != NULL
? ods->Flags
: memcpy(xmalloc(nb), ods->Flags, nb) );
- ds->Ft = ods->Ft;
ds->nopromote = ods->nopromote;
/*@-assignexpose@*/
ds->EVRcmp = ods->EVRcmp;;
@@ -3724,7 +3716,7 @@
int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote)
{
- HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+ HGE_t hge = (HGE_t)headerGetEntry;
const char * pkgN, * V, * R;
int_32 * epoch;
const char * pkgEVR;
@@ .
patch -p0 <<'@@ .'
Index: rpm/lib/rpmds.h
============================================================================
$ cvs diff -u -r2.58 -r2.59 rpmds.h
--- rpm/lib/rpmds.h 6 Oct 2007 21:33:48 -0000 2.58
+++ rpm/lib/rpmds.h 13 Oct 2007 17:50:06 -0000 2.59
@@ -56,7 +56,6 @@
const char * A; /*!< Arch (from containing package). */
int_32 BT; /*!< Package build time tie breaker. */
rpmTag tagN; /*!< Header tag. */
- rpmTagType Nt, EVRt, Ft; /*!< Tag data types. */
int_32 Count; /*!< No. of elements */
int i; /*!< Element index. */
unsigned l; /*!< Low element (bsearch). */
@@ .
Received on Sat Oct 13 19:50:06 2007