Avoid changing the dependency sets when looking up from rpmal
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 5 Oct 2012 07:16:44 +0000 (10:16 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 5 Oct 2012 07:16:44 +0000 (10:16 +0300)
- Use indexed access and comparison to avoid mucking around with
  eg transaction element dependency sets while the callers are walking
  over them.

lib/rpmal.c

index 63a70e2..d3bac97 100644 (file)
@@ -357,7 +357,7 @@ static rpmte * rpmalAllFileSatisfiesDepend(const rpmal al, const char *fileName)
 rpmte * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds)
 {
     rpmte * ret = NULL;
-    int i, found;
+    int i, ix, found;
     rpmsid nameId;
     const char *name;
     availableIndexEntry result;
@@ -397,15 +397,13 @@ rpmte * rpmalAllSatisfiesDepend(const rpmal al, const rpmds ds)
        alp = al->list + result[i].pkgNum;
        if (alp->p == NULL) // deleted
            continue;
-       (void) rpmdsSetIx(alp->provides, result[i].entryIx);
+       ix = result[i].entryIx;
 
        /* Obsoletes are on package name, filter out other provide matches */
-       if (obsolete && !rstreq(rpmdsN(alp->provides), rpmteN(alp->p)))
+       if (obsolete && !rstreq(rpmdsNIndex(alp->provides, ix), rpmteN(alp->p)))
            continue;
 
-       rc = 0;
-       if (rpmdsIx(alp->provides) >= 0)
-           rc = rpmdsCompare(alp->provides, ds);
+       rc = rpmdsCompareIndex(alp->provides, ix, ds, rpmdsIx(ds));
 
        if (rc) {
            rpmdsNotify(ds, "(added provide)", 0);