summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-13 10:56:42 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-13 11:01:09 +0300
commit9816b07560afa17f396467229cafd136fad46d61 (patch)
tree9e08056b08587374ee6f1c81af7152d92a1d9d23
parentf3f4c74748fe75c819ecdd711dfa451024d1c241 (diff)
downloadrpm-9816b07560afa17f396467229cafd136fad46d61.tar.gz
rpm-9816b07560afa17f396467229cafd136fad46d61.tar.bz2
rpm-9816b07560afa17f396467229cafd136fad46d61.zip
Add pool-aware versions of rpmdsThis() and rpmdsSingle()
- Pooh ... I mean pool ... bah. The previous versions become simple wrappers to the pool-aware ones, using a private pool always. rpmdsCurrent() doesn't need pool-variant as its inherits its pool from the parent.
-rw-r--r--lib/rpmds.c28
-rw-r--r--lib/rpmds.h23
2 files changed, 44 insertions, 7 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c
index a7d27b383..d21944c5a 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -297,33 +297,47 @@ exit:
return ds;
}
-static rpmds singleDS(rpmTagVal tagN, const char * N, const char * EVR,
+static rpmds singleDS(rpmstrPool pool, rpmTagVal tagN,
+ const char * N, const char * EVR,
rpmsenseFlags Flags, unsigned int instance,
rpm_color_t Color)
{
- rpmds ds = singleDSPool(NULL, tagN, 0, 0, Flags, instance, Color);
+ rpmds ds = singleDSPool(pool, tagN, 0, 0, Flags, instance, Color);
if (ds) {
/* now that we have a pool, we can insert our N & EVR strings */
ds->N[0] = rpmstrPoolId(ds->pool, N ? N : "", 1);
ds->EVR[0] = rpmstrPoolId(ds->pool, EVR ? EVR : "", 1);
- /* freeze the pool to save memory */
- rpmstrPoolFreeze(ds->pool, 0);
+ /* freeze the pool to save memory, but only if private pool */
+ if (ds->pool != pool)
+ rpmstrPoolFreeze(ds->pool, 0);
}
return ds;
}
-rpmds rpmdsThis(Header h, rpmTagVal tagN, rpmsenseFlags Flags)
+rpmds rpmdsThisPool(rpmstrPool pool,
+ Header h, rpmTagVal tagN, rpmsenseFlags Flags)
{
char *evr = headerGetAsString(h, RPMTAG_EVR);
- rpmds ds = singleDS(tagN, headerGetString(h, RPMTAG_NAME),
+ rpmds ds = singleDS(pool, tagN, headerGetString(h, RPMTAG_NAME),
evr, Flags, headerGetInstance(h), 0);
free(evr);
return ds;
}
+rpmds rpmdsThis(Header h, rpmTagVal tagN, rpmsenseFlags Flags)
+{
+ return rpmdsThisPool(NULL, h, tagN, Flags);
+}
+
+rpmds rpmdsSinglePool(rpmstrPool pool,rpmTagVal tagN,
+ const char * N, const char * EVR, rpmsenseFlags Flags)
+{
+ return singleDS(pool, tagN, N, EVR, Flags, 0, 0);
+}
+
rpmds rpmdsSingle(rpmTagVal tagN, const char * N, const char * EVR, rpmsenseFlags Flags)
{
- return singleDS(tagN, N, EVR, Flags, 0, 0);
+ return rpmdsSinglePool(NULL, tagN, N, EVR, Flags);
}
rpmds rpmdsCurrent(rpmds ds)
diff --git a/lib/rpmds.h b/lib/rpmds.h
index 0a4f27f1f..8b5e8136c 100644
--- a/lib/rpmds.h
+++ b/lib/rpmds.h
@@ -136,6 +136,17 @@ char * rpmdsNewDNEVR(const char * dspfx, const rpmds ds);
rpmds rpmdsThis(Header h, rpmTagVal tagN, rpmsenseFlags Flags);
/** \ingroup rpmds
+ * Create, load and initialize a dependency for this header.
+ * @param pool string pool (or NULL for private pool)
+ * @param h header
+ * @param tagN type of dependency
+ * @param Flags comparison flags
+ * @return new dependency set
+ */
+rpmds rpmdsThisPool(rpmstrPool pool,
+ Header h, rpmTagVal tagN, rpmsenseFlags Flags);
+
+/** \ingroup rpmds
* Create, load and initialize a dependency set of size 1.
* @param tagN type of dependency
* @param N name
@@ -146,6 +157,18 @@ rpmds rpmdsThis(Header h, rpmTagVal tagN, rpmsenseFlags Flags);
rpmds rpmdsSingle(rpmTagVal tagN, const char * N, const char * EVR, rpmsenseFlags Flags);
/** \ingroup rpmds
+ * Create, load and initialize a dependency set of size 1.
+ * @param pool string pool (or NULL for private pool)
+ * @param tagN type of dependency
+ * @param N name
+ * @param EVR epoch:version-release
+ * @param Flags comparison flags
+ * @return new dependency set
+ */
+rpmds rpmdsSinglePool(rpmstrPool pool, rpmTagVal tagN,
+ const char * N, const char * EVR, rpmsenseFlags Flags);
+
+/** \ingroup rpmds
* Return a new dependency set of size 1 from the current iteration index
* @param ds dependency set
* @return new dependency set