Add pool-aware version of rpmdsRpmlib()
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 13 Sep 2012 08:54:54 +0000 (11:54 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 13 Sep 2012 08:54:54 +0000 (11:54 +0300)
lib/rpmds.c
lib/rpmds.h

index d21944c..2ed3d8d 100644 (file)
@@ -982,7 +982,7 @@ static const struct rpmlibProvides_s rpmlibProvides[] = {
 };
 
 
-int rpmdsRpmlib(rpmds * dsp, const void * tblp)
+int rpmdsRpmlibPool(rpmstrPool pool, rpmds * dsp, const void * tblp)
 {
     const struct rpmlibProvides_s * rltblp = tblp;
     const struct rpmlibProvides_s * rlp;
@@ -992,16 +992,22 @@ int rpmdsRpmlib(rpmds * dsp, const void * tblp)
        rltblp = rpmlibProvides;
 
     for (rlp = rltblp; rlp->featureName != NULL && rc == 0; rlp++) {
-       rpmds ds = rpmdsSingle(RPMTAG_PROVIDENAME, rlp->featureName,
+       rpmds ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME, rlp->featureName,
                        rlp->featureEVR, rlp->featureFlags);
        rc = rpmdsMerge(dsp, ds);
        rpmdsFree(ds);
     }
-    if (*dsp)
+    /* freeze the pool to save memory, but only if private pool */
+    if (*dsp && (*dsp)->pool != pool)
        rpmstrPoolFreeze((*dsp)->pool, 0);
     return rc;
 }
 
+int rpmdsRpmlib(rpmds * dsp, const void * tblp)
+{
+    return rpmdsRpmlibPool(NULL, dsp, tblp);
+}
+
 rpmstrPool rpmdsPool(rpmds ds)
 {
     return (ds != NULL) ? ds->pool : NULL;
index 8b5e813..9127e51 100644 (file)
@@ -385,6 +385,15 @@ int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
  */
 int rpmdsRpmlib(rpmds * dsp, const void * tblp);
 
+/**
+ * Load rpmlib provides into a dependency set.
+ * @param pool         shared string pool (or NULL for private pool)
+ * @retval *dsp                (loaded) depedency set
+ * @param tblp         rpmlib provides table (NULL uses internal table)
+ * @return             0 on success
+ */
+int rpmdsRpmlibPool(rpmstrPool pool, rpmds * dsp, const void * tblp);
+
 /** \ingroup rpmds
  * Return dependency set string pool handle
  * @param fi           dependency set