summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-05-16 20:02:08 +0000
committerjbj <devnull@localhost>2001-05-16 20:02:08 +0000
commit2622029162ad26cf8463ac7026db9d85ca254cf9 (patch)
tree7681db1d81e8a182d8b019de52e31f36f8ab396d /lib
parentcec2fe637a8b872282e7029867a253384ed1d553 (diff)
downloadlibrpm-tizen-2622029162ad26cf8463ac7026db9d85ca254cf9.tar.gz
librpm-tizen-2622029162ad26cf8463ac7026db9d85ca254cf9.tar.bz2
librpm-tizen-2622029162ad26cf8463ac7026db9d85ca254cf9.zip
fix: rpmtransAddPackage assumed removed packages were sorted (#35827).
CVS patchset: 4797 CVS date: 2001/05/16 20:02:08
Diffstat (limited to 'lib')
-rw-r--r--lib/depends.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/lib/depends.c b/lib/depends.c
index 0cefc9e71..6f2206984 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -464,20 +464,6 @@ static void alMakeIndex(struct availableList * al)
}
/**
- * Compare removed package instances (qsort/bsearch).
- * @param a 1st instance address
- * @param b 2nd instance address
- * @return result of comparison
- */
-static int intcmp(const void * a, const void *b)
-{
- const int * aptr = a;
- const int * bptr = b;
- int rc = (*aptr - *bptr);
- return rc;
-}
-
-/**
* Split EVR into epoch, version, and release components.
* @param evr [epoch:]version[-release] string
* @retval *ep pointer to epoch
@@ -731,6 +717,20 @@ rpmTransactionSet rpmtransCreateSet(rpmdb rpmdb, const char * rootDir)
}
/**
+ * Compare removed package instances (qsort/bsearch).
+ * @param a 1st instance address
+ * @param b 2nd instance address
+ * @return result of comparison
+ */
+static int intcmp(const void * a, const void *b)
+{
+ const int * aptr = a;
+ const int * bptr = b;
+ int rc = (*aptr - *bptr);
+ return rc;
+}
+
+/**
* Add removed package instance to ordered transaction set.
* @param ts transaction set
* @param dboffset rpm database instance
@@ -739,12 +739,13 @@ rpmTransactionSet rpmtransCreateSet(rpmdb rpmdb, const char * rootDir)
static void removePackage(rpmTransactionSet ts, int dboffset, int depends)
/*@modifies ts @*/
{
- int i;
/* Filter out duplicate erasures. */
- if (ts->removedPackages != NULL)
- for (i = 0; i < ts->numRemovedPackages; i++)
- if (dboffset == ts->removedPackages[i]) return;
+ if (ts->numRemovedPackages > 0 && ts->removedPackages != NULL) {
+ if (bsearch(&dboffset, ts->removedPackages, ts->numRemovedPackages,
+ sizeof(int), intcmp) != NULL)
+ return;
+ }
if (ts->numRemovedPackages == ts->allocedRemovedPackages) {
ts->allocedRemovedPackages += ts->delta;
@@ -752,7 +753,10 @@ static void removePackage(rpmTransactionSet ts, int dboffset, int depends)
sizeof(int *) * ts->allocedRemovedPackages);
}
- ts->removedPackages[ts->numRemovedPackages++] = dboffset;
+ if (ts->removedPackages != NULL) { /* XXX can't happen. */
+ ts->removedPackages[ts->numRemovedPackages++] = dboffset;
+ qsort(ts->removedPackages, ts->numRemovedPackages, sizeof(int), intcmp);
+ }
if (ts->orderCount == ts->orderAlloced) {
ts->orderAlloced += ts->delta;
@@ -1976,8 +1980,6 @@ int rpmdepCheck(rpmTransactionSet ts,
*conflicts = NULL;
*numConflicts = 0;
- qsort(ts->removedPackages, ts->numRemovedPackages, sizeof(int), intcmp);
-
alMakeIndex(&ts->addedPackages);
alMakeIndex(&ts->availablePackages);