summaryrefslogtreecommitdiff
path: root/lib/fprint.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-13 21:52:38 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-14 13:31:33 +0300
commit33b900fc03486e5cf3fd22373cf3187fbdffbea0 (patch)
treec429a51e8908be7691736acbfba485f47f8b0fa2 /lib/fprint.c
parent56ba2dc3accddb783ae07f37a2fc8c4347fe04cc (diff)
downloadlibrpm-tizen-33b900fc03486e5cf3fd22373cf3187fbdffbea0.tar.gz
librpm-tizen-33b900fc03486e5cf3fd22373cf3187fbdffbea0.tar.bz2
librpm-tizen-33b900fc03486e5cf3fd22373cf3187fbdffbea0.zip
Hide by-fingerprint hash into fingerprint cache, add minimal API bits
- For now, always create the by-fingerprint hash although rpmdb usage doesn't need it. Next steps will fix... - Add wrapper API for retrieving the records, adjust callers - No functional changes, at least intended ones... just first steps towards eliminating the hash-jungle and forcing a single API through which this stuff gets handled
Diffstat (limited to 'lib/fprint.c')
-rw-r--r--lib/fprint.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/fprint.c b/lib/fprint.c
index 44e490031..f72a149f8 100644
--- a/lib/fprint.c
+++ b/lib/fprint.c
@@ -29,16 +29,19 @@
*/
struct fprintCache_s {
rpmFpEntryHash ht; /*!< hashed by dirName */
+ rpmFpHash fp; /*!< hashed by fingerprint */
};
fingerPrintCache fpCacheCreate(int sizeHint)
{
fingerPrintCache fpc;
- fpc = xmalloc(sizeof(*fpc));
+ fpc = xcalloc(1, sizeof(*fpc));
fpc->ht = rpmFpEntryHashCreate(sizeHint, rstrhash, strcmp,
(rpmFpEntryHashFreeKey)free,
(rpmFpEntryHashFreeData)free);
+ fpc->fp = rpmFpHashCreate(sizeHint, fpHashFunction, fpEqual,
+ NULL, NULL);
return fpc;
}
@@ -46,6 +49,7 @@ fingerPrintCache fpCacheFree(fingerPrintCache cache)
{
if (cache) {
cache->ht = rpmFpEntryHashFree(cache->ht);
+ cache->fp = rpmFpHashFree(cache->fp);
free(cache);
}
return NULL;
@@ -241,7 +245,7 @@ void fpLookupList(fingerPrintCache cache, rpmstrPool pool,
}
}
-void fpLookupSubdir(rpmFpHash symlinks, rpmFpHash fphash, fingerPrintCache fpc, rpmte p, int filenr)
+void fpLookupSubdir(rpmFpHash symlinks, fingerPrintCache fpc, rpmte p, int filenr)
{
rpmfi fi = rpmteFI(p);
struct fingerPrint_s current_fp;
@@ -256,7 +260,7 @@ void fpLookupSubdir(rpmFpHash symlinks, rpmFpHash fphash, fingerPrintCache fpc,
struct rpmffi_s ffi = { p, filenr};
if (fp->subDir == NULL) {
- rpmFpHashAddEntry(fphash, fp, ffi);
+ rpmFpHashAddEntry(fpc->fp, fp, ffi);
return;
}
@@ -309,7 +313,7 @@ void fpLookupSubdir(rpmFpHash symlinks, rpmFpHash fphash, fingerPrintCache fpc,
current_fp = *fp;
if (fp->subDir == NULL) {
/* directory exists - no need to look for symlinks */
- rpmFpHashAddEntry(fphash, fp, ffi);
+ rpmFpHashAddEntry(fpc->fp, fp, ffi);
return;
}
lensubDir = strlen(fp->subDir);
@@ -355,6 +359,12 @@ void fpLookupSubdir(rpmFpHash symlinks, rpmFpHash fphash, fingerPrintCache fpc,
}
free(currentsubdir);
- rpmFpHashAddEntry(fphash, fp, ffi);
+ rpmFpHashAddEntry(fpc->fp, fp, ffi);
}
+
+int fpCacheGetByFp(fingerPrintCache cache, struct fingerPrint_s * fp,
+ struct rpmffi_s ** recs, int * numRecs)
+{
+ return rpmFpHashGetEntry(cache->fp, fp, recs, numRecs, NULL);
+}