From 5bad56b4ab36b71e5d1874073bdcf81665809c53 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 14 Sep 2012 14:21:10 +0300 Subject: [PATCH] Allow passing a shared pool for finger print cache - Both callers updated to still use a private pool so no practical change here. --- lib/fprint.c | 4 ++-- lib/fprint.h | 3 ++- lib/rpmdb.c | 2 +- lib/transaction.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/fprint.c b/lib/fprint.c index 2f6f1d5..552534b 100644 --- a/lib/fprint.c +++ b/lib/fprint.c @@ -90,14 +90,14 @@ struct fprintCache_s { rpmstrPool pool; /*!< string pool */ }; -fingerPrintCache fpCacheCreate(int sizeHint) +fingerPrintCache fpCacheCreate(int sizeHint, rpmstrPool pool) { fingerPrintCache fpc; fpc = xcalloc(1, sizeof(*fpc)); fpc->ht = rpmFpEntryHashCreate(sizeHint, sidHash, sidCmp, NULL, (rpmFpEntryHashFreeData)free); - fpc->pool = rpmstrPoolCreate(); + fpc->pool = (pool != NULL) ? rpmstrPoolLink(pool) : rpmstrPoolCreate(); return fpc; } diff --git a/lib/fprint.h b/lib/fprint.h index ca0f6fc..ea3a73b 100644 --- a/lib/fprint.h +++ b/lib/fprint.h @@ -29,10 +29,11 @@ extern "C" { /** * Create finger print cache. * @param sizeHint number of elements expected + * @param pool string pool (or NULL for private) * @return pointer to initialized fingerprint cache */ RPM_GNUC_INTERNAL -fingerPrintCache fpCacheCreate(int sizeHint); +fingerPrintCache fpCacheCreate(int sizeHint, rpmstrPool pool); /** * Destroy finger print cache. diff --git a/lib/rpmdb.c b/lib/rpmdb.c index c024e7d..a83b902 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -958,7 +958,7 @@ static int rpmdbFindByFile(rpmdb db, dbiIndex dbi, const char *filespec, if (rc || allMatches == NULL) goto exit; *matches = xcalloc(1, sizeof(**matches)); - fpc = fpCacheCreate(allMatches->count); + fpc = fpCacheCreate(allMatches->count, NULL); fpLookup(fpc, dirName, baseName, &fp1); i = 0; diff --git a/lib/transaction.c b/lib/transaction.c index ba8564e..008fe15 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -1293,7 +1293,7 @@ static int rpmtsPrepare(rpmts ts) /* Required for now to lock string pointers in memory */ rpmstrPoolFreeze(tsmem->pool, 1); - fingerPrintCache fpc = fpCacheCreate(fileCount/2 + 10001); + fingerPrintCache fpc = fpCacheCreate(fileCount/2 + 10001, NULL); rpmlog(RPMLOG_DEBUG, "computing %" PRIu64 " file fingerprints\n", fileCount); -- 2.7.4