Allow passing a shared pool for finger print cache
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 14 Sep 2012 11:21:10 +0000 (14:21 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 14 Sep 2012 11:21:10 +0000 (14:21 +0300)
- Both callers updated to still use a private pool so no practical
  change here.

lib/fprint.c
lib/fprint.h
lib/rpmdb.c
lib/transaction.c

index 2f6f1d5..552534b 100644 (file)
@@ -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;
 }
 
index ca0f6fc..ea3a73b 100644 (file)
@@ -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.
index c024e7d..a83b902 100644 (file)
@@ -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;
index ba8564e..008fe15 100644 (file)
@@ -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);