mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-15 06:59:58 -05:00
idxset: Allow deep copying with pa_idxset_copy()
This commit is contained in:
parent
5c860fe06d
commit
d1fd31d50f
4 changed files with 9 additions and 13 deletions
|
|
@ -458,7 +458,7 @@ bool pa_idxset_isempty(pa_idxset *s) {
|
|||
return s->n_entries == 0;
|
||||
}
|
||||
|
||||
pa_idxset *pa_idxset_copy(pa_idxset *s) {
|
||||
pa_idxset *pa_idxset_copy(pa_idxset *s, pa_copy_func_t copy_func) {
|
||||
pa_idxset *copy;
|
||||
struct idxset_entry *i;
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ pa_idxset *pa_idxset_copy(pa_idxset *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);
|
||||
pa_idxset_put(copy, copy_func ? copy_func(i->data) : i->data, NULL);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ int pa_idxset_string_compare_func(const void *a, const void *b);
|
|||
|
||||
typedef unsigned (*pa_hash_func_t)(const void *p);
|
||||
typedef int (*pa_compare_func_t)(const void *a, const void *b);
|
||||
typedef void *(*pa_copy_func_t)(const void *p);
|
||||
|
||||
typedef struct pa_idxset pa_idxset;
|
||||
|
||||
|
|
@ -105,8 +106,10 @@ unsigned pa_idxset_size(pa_idxset*s);
|
|||
/* Return true of the idxset is empty */
|
||||
bool pa_idxset_isempty(pa_idxset *s);
|
||||
|
||||
/* Duplicate the idxset. This will not copy the actual indexes */
|
||||
pa_idxset *pa_idxset_copy(pa_idxset *s);
|
||||
/* Duplicate the idxset. This will not copy the actual indexes. If copy_func is
|
||||
* set, each entry is copied using the provided function, otherwise a shallow
|
||||
* copy will be made. */
|
||||
pa_idxset *pa_idxset_copy(pa_idxset *s, pa_copy_func_t copy_func);
|
||||
|
||||
/* A macro to ease iteration through all entries */
|
||||
#define PA_IDXSET_FOREACH(e, s, idx) \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue