From: Lennart Poettering Date: Wed, 17 Jun 2009 01:01:40 +0000 (+0200) Subject: idxset: implement pa_idxset_copy() X-Git-Tag: submit/2.0-panda/20130828.192557~1725 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=277e8c5ce4cf055108bc8ba17d079a7318932fd2;p=profile%2Fivi%2Fpulseaudio-panda.git idxset: implement pa_idxset_copy() --- diff --git a/src/pulsecore/idxset.c b/src/pulsecore/idxset.c index 352ac97..408011f 100644 --- a/src/pulsecore/idxset.c +++ b/src/pulsecore/idxset.c @@ -453,3 +453,17 @@ pa_bool_t pa_idxset_isempty(pa_idxset *s) { return s->n_entries == 0; } + +pa_idxset *pa_idxset_copy(pa_idxset *s) { + pa_idxset *copy; + struct idxset_entry *i; + + pa_assert(s); + + copy = pa_idxset_new(s->hash_func, s->compare_func); + + for (i = s->iterate_list_head; i; i = i->iterate_next) + pa_idxset_put(copy, i->data, NULL); + + return copy; +} diff --git a/src/pulsecore/idxset.h b/src/pulsecore/idxset.h index a6179fc..d1e68c5 100644 --- a/src/pulsecore/idxset.h +++ b/src/pulsecore/idxset.h @@ -103,6 +103,9 @@ unsigned pa_idxset_size(pa_idxset*s); /* Return TRUE of the idxset is empty */ pa_bool_t pa_idxset_isempty(pa_idxset *s); +/* Duplicate the idxset. This will not copy the actual indexes */ +pa_idxset *pa_idxset_copy(pa_idxset *s); + /* A macro to ease iteration through all entries */ #define PA_IDXSET_FOREACH(e, s, idx) \ for ((e) = pa_idxset_first((s), &(idx)); (e); (e) = pa_idxset_next((s), &(idx)))