summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/fprint.c17
-rw-r--r--lib/fprint.h2
-rw-r--r--lib/rpmdb.c5
-rw-r--r--lib/transaction.c12
4 files changed, 20 insertions, 16 deletions
diff --git a/lib/fprint.c b/lib/fprint.c
index a31e54619..a0aef4a5b 100644
--- a/lib/fprint.c
+++ b/lib/fprint.c
@@ -108,7 +108,7 @@ static const struct fprintCacheEntry_s * cacheContainsDirectory(
return NULL;
}
-int fpLookup(fingerPrintCache cache,
+static int doLookup(fingerPrintCache cache,
const char * dirName, const char * baseName, int scareMemory,
fingerPrint *fp)
{
@@ -230,6 +230,15 @@ exit:
return 0;
}
+int fpLookup(fingerPrintCache cache,
+ const char * dirName, const char * baseName, int scareMemory,
+ fingerPrint **fp)
+{
+ if (*fp == NULL)
+ *fp = xcalloc(1, sizeof(**fp));
+ return doLookup(cache, dirName, baseName, scareMemory, *fp);
+}
+
/**
* Return hash value for a finger print.
* Hash based on dev and inode only!
@@ -277,7 +286,7 @@ int fpLookupEquals(fingerPrintCache cache, fingerPrint *fp,
const char * dirName, const char * baseName)
{
struct fingerPrint_s ofp;
- fpLookup(cache, dirName, baseName, 1, &ofp);
+ doLookup(cache, dirName, baseName, 1, &ofp);
return FP_EQUAL(*fp, ofp);
}
@@ -297,7 +306,7 @@ fingerPrint * fpLookupList(fingerPrintCache cache, rpmstrPool pool,
fps[i].subDir = fps[i - 1].subDir;
fps[i].baseName = rpmstrPoolStr(pool, baseNames[i]);
} else {
- fpLookup(cache,
+ doLookup(cache,
rpmstrPoolStr(pool, dirNames[dirIndexes[i]]),
rpmstrPoolStr(pool, baseNames[i]),
1, &fps[i]);
@@ -364,7 +373,7 @@ static void fpLookupSubdir(rpmFpHash symlinks, fingerPrintCache fpc, rpmte p, in
rstrscat(&link, endbasename+1, "/", NULL);
}
- fpLookup(fpc, link, fp->baseName, 0, fp);
+ doLookup(fpc, link, fp->baseName, 0, fp);
free(link);
free(currentsubdir);
diff --git a/lib/fprint.h b/lib/fprint.h
index 148675354..2a2b7cf03 100644
--- a/lib/fprint.h
+++ b/lib/fprint.h
@@ -84,7 +84,7 @@ dev_t fpEntryDev(fingerPrintCache cache, fingerPrint *fp);
RPM_GNUC_INTERNAL
int fpLookup(fingerPrintCache cache,
const char * dirName, const char * baseName, int scareMemory,
- fingerPrint *fp);
+ fingerPrint **fp);
/**
* Compare two finger print entries.
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index a6600cd31..22d2fe762 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -933,7 +933,7 @@ static int rpmdbFindByFile(rpmdb db, dbiIndex dbi, const char *filespec,
char * dirName = NULL;
const char * baseName;
fingerPrintCache fpc = NULL;
- fingerPrint fp1;
+ fingerPrint * fp1 = NULL;
dbiIndexSet allMatches = NULL;
unsigned int i;
int rc = -2; /* assume error */
@@ -997,7 +997,7 @@ static int rpmdbFindByFile(rpmdb db, dbiIndex dbi, const char *filespec,
if (!skip) {
const char *dirName = dirNames[dirIndexes[num]];
- if (fpLookupEquals(fpc, &fp1, dirName, baseNames[num])) {
+ if (fpLookupEquals(fpc, fp1, dirName, baseNames[num])) {
struct dbiIndexItem rec = {
.hdrNum = dbiIndexRecordOffset(allMatches, i),
.tagNum = dbiIndexRecordFileNumber(allMatches, i),
@@ -1020,6 +1020,7 @@ static int rpmdbFindByFile(rpmdb db, dbiIndex dbi, const char *filespec,
headerFree(h);
}
+ free(fp1);
fpCacheFree(fpc);
if ((*matches)->count == 0) {
diff --git a/lib/transaction.c b/lib/transaction.c
index 8bcf5aac3..1b00194a1 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -971,7 +971,7 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, fingerPrintCache fpc)
while (h != NULL) {
headerGetFlags hgflags = HEADERGET_MINMEM;
struct rpmtd_s bnames, dnames, dindexes, ostates;
- fingerPrint fp, *fpp;
+ fingerPrint *fpp = NULL;
unsigned int installedPkg;
int beingRemoved = 0;
rpmfi otherFi = NULL;
@@ -1014,14 +1014,7 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, fingerPrintCache fpc)
dirName = rpmtdGetString(&dnames);
baseName = rpmtdGetString(&bnames);
- if (dirName == oldDir) {
- /* directory is the same as last round */
- fp.baseName = baseName;
- } else {
- fpLookup(fpc, dirName, baseName, 1, &fp);
- oldDir = dirName;
- }
- fpp = &fp;
+ fpLookup(fpc, dirName, baseName, 1, &fpp);
} else {
fpp = rpmfiFpsIndex(otherFi, fileNum);
}
@@ -1063,6 +1056,7 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, fingerPrintCache fpc)
rpmtdFreeData(&bnames);
rpmtdFreeData(&dnames);
rpmtdFreeData(&dindexes);
+ free(fpp);
}
headerFree(h);
h = newheader;