deal with fpCacheCreate() size parameter

This commit is contained in:
Alexey Tourbin 2009-03-25 16:37:43 +03:00
parent 02104ae61f
commit dba96abac5
3 changed files with 7 additions and 9 deletions

View File

@ -1774,7 +1774,8 @@ int rpmRunTransactions( rpmTransactionSet ts,
}
ht = htCreate(totalFileCount, fpHashFunction, fpEqual);
fpc = fpCacheCreate(totalFileCount);
/* XXX fpCache size = directories + space for rpmdbFindFpList */
fpc = fpCacheCreate(totalFileCount / 2 + 4096);
/* ===============================================
* Add fingerprint for each file not skipped.

View File

@ -88,7 +88,7 @@ int rpmdbFindFpList(/*@null@*/ rpmdb db, fingerPrint * fpList,
/**
* Create finger print cache.
* @param size number of elements expected
* @param size number of directories expected
* @return pointer to initialized fingerprint cache
*/
/*@only@*/ fingerPrintCache fpCacheCreate(unsigned int size)

View File

@ -1176,8 +1176,6 @@ static int rpmdbFindByFile(rpmdb db, /*@null@*/ const char * filespec,
const char * dirName;
const char * baseName;
rpmTagType bnt, dnt;
fingerPrintCache fpc;
fingerPrint fp1;
dbiIndex dbi = NULL;
DBC * dbcursor;
dbiIndexSet allMatches = NULL;
@ -1206,9 +1204,6 @@ static int rpmdbFindByFile(rpmdb db, /*@null@*/ const char * filespec,
if (baseName == NULL)
return -2;
fpc = fpCacheCreate(20);
fp1 = fpLookup(fpc, dirName, baseName, 1);
dbi = dbiOpen(db, RPMTAG_BASENAMES, 0);
if (dbi != NULL) {
dbcursor = NULL;
@ -1221,14 +1216,16 @@ static int rpmdbFindByFile(rpmdb db, /*@null@*/ const char * filespec,
if (rc) {
allMatches = dbiFreeIndexSet(allMatches);
fpCacheFree(fpc);
return rc;
}
assert(allMatches && allMatches->count > 0);
fingerPrintCache fpc = fpCacheCreate(allMatches->count);
fingerPrint fp1 = fpLookup(fpc, dirName, baseName, 1);
*matches = xcalloc(1, sizeof(**matches));
rec = dbiIndexNewItem(0, 0);
i = 0;
if (allMatches != NULL)
while (i < allMatches->count) {
const char ** baseNames, ** dirNames;
int_32 * dirIndexes;