Add dbiIndexSetPruneSet helper
Also make pruning from an empty set non-fatal.
This commit is contained in:
parent
a0e92e8b1f
commit
8d54160ece
|
@ -126,7 +126,9 @@ int dbiIndexSetPrune(dbiIndexSet set, dbiIndexItem recs,
|
|||
unsigned int numCopied = 0;
|
||||
size_t recsize = sizeof(*recs);
|
||||
|
||||
assert(set->count > 0);
|
||||
if (num == 0 || nrecs == 0)
|
||||
return 1;
|
||||
|
||||
if (nrecs > 1 && !sorted)
|
||||
qsort(recs, nrecs, recsize, hdrNumCmp);
|
||||
|
||||
|
@ -143,6 +145,13 @@ int dbiIndexSetPrune(dbiIndexSet set, dbiIndexItem recs,
|
|||
return (numCopied == num);
|
||||
}
|
||||
|
||||
int dbiIndexSetPruneSet(dbiIndexSet set, dbiIndexSet oset, int sortset)
|
||||
{
|
||||
if (oset == NULL)
|
||||
return 1;
|
||||
return dbiIndexSetPrune(set, oset->recs, oset->count, sortset);
|
||||
}
|
||||
|
||||
unsigned int dbiIndexSetCount(dbiIndexSet set)
|
||||
{
|
||||
return (set != NULL) ? set->count : 0;
|
||||
|
|
|
@ -76,6 +76,16 @@ RPM_GNUC_INTERNAL
|
|||
int dbiIndexSetPrune(dbiIndexSet set, dbiIndexItem recs,
|
||||
unsigned int nrecs, int sorted);
|
||||
|
||||
/**
|
||||
* Remove an index set from another.
|
||||
* @param set set of index database items
|
||||
* @param oset set of entries that should be removed
|
||||
* @param sorted oset is already sorted?
|
||||
* @return 0 success, 1 failure (no items found)
|
||||
*/
|
||||
RPM_GNUC_INTERNAL
|
||||
int dbiIndexSetPruneSet(dbiIndexSet set, dbiIndexSet oset, int sorted);
|
||||
|
||||
/* Count items in index database set. */
|
||||
RPM_GNUC_INTERNAL
|
||||
unsigned int dbiIndexSetCount(dbiIndexSet set);
|
||||
|
|
Loading…
Reference in New Issue