diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-09-07 15:48:45 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-09-07 15:48:45 +0300 |
commit | f0a9d2577b782e6f1222626877076946764df657 (patch) | |
tree | 19b73c4778ec90c1d6f4b212a5de6f9677fbbc6f /lib/rpmfi.c | |
parent | d2bb9d38c90d8028989cb414bf84b132b0bbc967 (diff) | |
download | librpm-tizen-f0a9d2577b782e6f1222626877076946764df657.tar.gz librpm-tizen-f0a9d2577b782e6f1222626877076946764df657.tar.bz2 librpm-tizen-f0a9d2577b782e6f1222626877076946764df657.zip |
Add an alternative rpmfi constructor to allow shared pool usage
- rpmfiNewPool() allows specifying shared/private pool, and
rpmfiNew() is now just a wrapper to always call it with a private pool.
Diffstat (limited to 'lib/rpmfi.c')
-rw-r--r-- | lib/rpmfi.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 1a8a79c97..678612152 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -1084,7 +1084,7 @@ static rpmsid * tag2pool(rpmstrPool pool, Header h, rpmTag tag) if (headerGet((_h), (_tag), (_td), (_flags))) \ _data = (td.data) -rpmfi rpmfiNew(const rpmts ts, Header h, rpmTagVal tagN, rpmfiFlags flags) +rpmfi rpmfiNewPool(rpmstrPool pool, Header h, rpmTagVal tagN, rpmfiFlags flags) { rpmfi fi = xcalloc(1, sizeof(*fi)); unsigned char * t; @@ -1121,7 +1121,8 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTagVal tagN, rpmfiFlags flags) /* XXX: ensure the global misc. pool exists */ if (miscpool == NULL) miscpool = rpmstrPoolCreate(); - fi->pool = rpmstrPoolCreate(); + /* private or shared pool? */ + fi->pool = (pool != NULL) ? rpmstrPoolLink(pool) : rpmstrPoolCreate(); /* XXX TODO: all these should be sanity checked, ugh... */ if (!(flags & RPMFI_NOFILEMODES)) @@ -1206,7 +1207,9 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTagVal tagN, rpmfiFlags flags) /* lazily alloced from rpmfiFN() */ fi->fn = NULL; - rpmstrPoolFreeze(fi->pool); + /* only freeze private pool */ + if (fi->pool != pool) + rpmstrPoolFreeze(fi->pool); exit: @@ -1222,6 +1225,11 @@ errxit: return NULL; } +rpmfi rpmfiNew(const rpmts ts, Header h, rpmTagVal tagN, rpmfiFlags flags) +{ + return rpmfiNewPool(NULL, h, tagN, flags); +} + void rpmfiSetFReplacedSizeIndex(rpmfi fi, int ix, rpm_loff_t newsize) { if (fi != NULL && ix >= 0 && ix < fi->fc) { |