]> code.delx.au - pulseaudio/commitdiff
idxset: implement pa_idxset_copy()
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jun 2009 01:01:40 +0000 (03:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Jun 2009 01:01:40 +0000 (03:01 +0200)
src/pulsecore/idxset.c
src/pulsecore/idxset.h

index 352ac9777e2cc1adbb50d8d833ddbf3801d8ee9b..408011f6b4974ef1cb1f306a86d5069277d2bb48 100644 (file)
@@ -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;
+}
index a6179fcf125940694a7f51b9ee1c9fb2f205c4bb..d1e68c5c48191344b4742ff874126256adafe66b 100644 (file)
@@ -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)))