diff options
-rw-r--r-- | lib/backend/dbiset.c | 11 | ||||
-rw-r--r-- | lib/backend/dbiset.h | 10 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/backend/dbiset.c b/lib/backend/dbiset.c index 9ad143f28..649ea8866 100644 --- a/lib/backend/dbiset.c +++ b/lib/backend/dbiset.c @@ -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; diff --git a/lib/backend/dbiset.h b/lib/backend/dbiset.h index 88182d24a..506375865 100644 --- a/lib/backend/dbiset.h +++ b/lib/backend/dbiset.h @@ -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); |