return NULL;
}
-int fpLookup(fingerPrintCache cache,
+static int doLookup(fingerPrintCache cache,
const char * dirName, const char * baseName, int scareMemory,
fingerPrint *fp)
{
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!
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);
}
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]);
rstrscat(&link, endbasename+1, "/", NULL);
}
- fpLookup(fpc, link, fp->baseName, 0, fp);
+ doLookup(fpc, link, fp->baseName, 0, fp);
free(link);
free(currentsubdir);
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 */
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),
headerFree(h);
}
+ free(fp1);
fpCacheFree(fpc);
if ((*matches)->count == 0) {
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;
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);
}
rpmtdFreeData(&bnames);
rpmtdFreeData(&dnames);
rpmtdFreeData(&dindexes);
+ free(fpp);
}
headerFree(h);
h = newheader;