Add an nternal rpmal create+populate helper function, use for erased packages
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 12 Sep 2012 09:30:44 +0000 (12:30 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 12 Sep 2012 09:30:44 +0000 (12:30 +0300)
- We'll need this shortly for added packages too...

lib/depends.c
lib/order.c
lib/rpmts_internal.h

index ad9b577..42c3b8e 100644 (file)
@@ -313,6 +313,22 @@ static int findPos(rpmts ts, rpm_color_t tscolor, Header h, int upgrade)
     return oc;
 }
 
+rpmal rpmtsCreateAl(rpmts ts, rpmElementTypes types)
+{
+    rpmal al = NULL;
+    if (ts) {
+       rpmte p;
+       rpmtsi pi;
+
+       al = rpmalCreate((rpmtsNElements(ts) / 4) + 1, rpmtsFlags(ts),
+                               rpmtsColor(ts), rpmtsPrefColor(ts));
+       pi = rpmtsiInit(ts);
+       while ((p = rpmtsiNext(pi, types)))
+           rpmalAdd(al, p);
+       rpmtsiFree(pi);
+    }
+    return al;
+}
 
 int rpmtsAddInstallElement(rpmts ts, Header h,
                        fnpyKey key, int upgrade, rpmRelocation * relocs)
index 0c8d1cb..c0ef547 100644 (file)
@@ -548,8 +548,7 @@ int rpmtsOrder(rpmts ts)
     rpmte * newOrder;
     int newOrderCount = 0;
     int rc;
-    rpmal erasedPackages = rpmalCreate(5, rpmtsFlags(ts),
-                                       rpmtsColor(ts), prefcolor);
+    rpmal erasedPackages;
     scc SCCs;
     int nelem = rpmtsNElements(ts);
     tsortInfo sortInfo = xcalloc(nelem, sizeof(struct tsortInfo_s));
@@ -558,11 +557,7 @@ int rpmtsOrder(rpmts ts)
     (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_ORDER), 0);
 
     /* Create erased package index. */
-    pi = rpmtsiInit(ts);
-    while ((p = rpmtsiNext(pi, TR_REMOVED)) != NULL) {
-        rpmalAdd(erasedPackages, p);
-    }
-    rpmtsiFree(pi);
+    erasedPackages = rpmtsCreateAl(ts, TR_REMOVED);
 
     for (int i = 0; i < nelem; i++) {
        sortInfo[i].te = tsmem->order[i];
index 60daf47..5d3240c 100644 (file)
@@ -74,6 +74,9 @@ extern "C" {
 RPM_GNUC_INTERNAL
 tsMembers rpmtsMembers(rpmts ts);
 
+RPM_GNUC_INTERNAL
+rpmal rpmtsCreateAl(rpmts ts, rpmElementTypes types);
+
 /* returns -1 for retry, 0 for ignore and 1 for not found */
 RPM_GNUC_INTERNAL
 int rpmtsSolve(rpmts ts, rpmds key);