diff options
Diffstat (limited to 'lib/backend/dbiset.c')
-rw-r--r-- | lib/backend/dbiset.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/backend/dbiset.c b/lib/backend/dbiset.c index ad0114e6e..290a9ba5e 100644 --- a/lib/backend/dbiset.c +++ b/lib/backend/dbiset.c @@ -75,30 +75,17 @@ void dbiIndexSetUniq(dbiIndexSet set, int sorted) } } -int dbiIndexSetAppendSet(dbiIndexSet dest, dbiIndexSet src, int sortset) -{ - if (dest == NULL || src == NULL || src->count == 0) - return 1; - - dbiIndexSetGrow(dest, src->count); - memcpy(dest->recs + dest->count, - src->recs, src->count * sizeof(*src->recs)); - dest->count += src->count; - - if (sortset && dest->count > 1) - qsort(dest->recs, dest->count, sizeof(*(dest->recs)), hdrNumCmp); - return 0; -} - int dbiIndexSetAppend(dbiIndexSet set, dbiIndexItem recs, unsigned int nrecs, int sortset) { - if (set == NULL || recs == NULL || nrecs == 0) + if (set == NULL || recs == NULL) return 1; - dbiIndexSetGrow(set, nrecs); - memcpy(set->recs + set->count, recs, nrecs * sizeof(*(set->recs))); - set->count += nrecs; + if (nrecs) { + dbiIndexSetGrow(set, nrecs); + memcpy(set->recs + set->count, recs, nrecs * sizeof(*(set->recs))); + set->count += nrecs; + } if (sortset && set->count > 1) qsort(set->recs, set->count, sizeof(*(set->recs)), hdrNumCmp); @@ -106,6 +93,14 @@ int dbiIndexSetAppend(dbiIndexSet set, dbiIndexItem recs, return 0; } +int dbiIndexSetAppendSet(dbiIndexSet set, dbiIndexSet oset, int sortset) +{ + if (oset == NULL) + return 1; + return dbiIndexSetAppend(set, oset->recs, oset->count, sortset); +} + + int dbiIndexSetPrune(dbiIndexSet set, dbiIndexItem recs, unsigned int nrecs, int sorted) { |