Avoid umphteen arguments to isNewDep() by creating the new ds earlier
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 16 Apr 2013 04:38:01 +0000 (07:38 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 7 Jun 2013 09:22:24 +0000 (12:22 +0300)
(cherry picked from commit 0dd6e4491be69f4fc3074ae3859fb03fd6226a41)

build/reqprov.c

index ca9773b..6ee2900 100644 (file)
 #include "build/rpmbuild_internal.h"
 #include "debug.h"
 
-static int isNewDep(rpmds *dsp, rpmTagVal nametag,
-                 const char *N, const char *EVR, rpmsenseFlags Flags,
+static int isNewDep(rpmds *dsp, rpmds bds,
                  Header h, rpmTagVal indextag, uint32_t index)
 {
     int isnew = 1;
-    rpmds bds = rpmdsSingle(nametag, N, EVR, Flags);
 
     if (!indextag) {
        /* With normal deps, we can just merge and see if anything got added */
@@ -40,7 +38,6 @@ static int isNewDep(rpmds *dsp, rpmTagVal nametag,
        rpmdsMerge(dsp, bds);
     }
 
-    rpmdsFree(bds);
     return isnew;
 }
 
@@ -53,7 +50,7 @@ int addReqProv(Package pkg, rpmTagVal tagN,
     rpmTagVal indextag = 0;
     rpmsenseFlags extra = RPMSENSE_ANY;
     Header h = pkg->header; /* just a shortcut */
-    rpmds *dsp = NULL;
+    rpmds newds, *dsp = NULL;
 
     switch (tagN) {
     case RPMTAG_PROVIDENAME:
@@ -104,8 +101,9 @@ int addReqProv(Package pkg, rpmTagVal tagN,
     if (EVR == NULL)
        EVR = "";
     
+    newds = rpmdsSingle(tagN, N, EVR, Flags);
     /* Avoid adding duplicate dependencies. */
-    if (isNewDep(dsp, tagN, N, EVR, Flags, h, indextag, index)) {
+    if (isNewDep(dsp, newds, h, indextag, index)) {
        headerPutString(h, tagN, N);
        headerPutString(h, versiontag, EVR);
        headerPutUint32(h, flagtag, &Flags, 1);
@@ -113,6 +111,7 @@ int addReqProv(Package pkg, rpmTagVal tagN,
            headerPutUint32(h, indextag, &index, 1);
        }
     }
+    rpmdsFree(newds);
 
     return 0;
 }