From 7dfeb1fc745757f1c2b7bf43bae80cf0f49fc9a6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 11 Jun 2004 21:30:16 +0000 Subject: make the whole stuff run and clean it self up again git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@8 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/idxset.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/idxset.c') diff --git a/src/idxset.c b/src/idxset.c index eaea34f4..f0d7ad87 100644 --- a/src/idxset.c +++ b/src/idxset.c @@ -27,7 +27,7 @@ static unsigned trivial_hash_func(void *p) { } static int trivial_compare_func(void *a, void *b) { - return !(a == b); + return a != b; } struct idxset* idxset_new(unsigned (*hash_func) (void *p), int (*compare_func) (void*a, void*b)) { @@ -40,11 +40,13 @@ struct idxset* idxset_new(unsigned (*hash_func) (void *p), int (*compare_func) ( s->hash_table_size = 1023; s->hash_table = malloc(sizeof(struct idxset_entry*)*s->hash_table_size); assert(s->hash_table); + memset(s->hash_table, 0, sizeof(struct idxset_entry*)*s->hash_table_size); s->array = NULL; s->array_size = 0; s->index = 0; s->start_index = 0; s->n_entries = 0; + s->rrobin = NULL; s->iterate_list_head = s->iterate_list_tail = NULL; @@ -75,7 +77,7 @@ static struct idxset_entry* hash_scan(struct idxset *s, struct idxset_entry* e, assert(s->compare_func); for (; e; e = e->hash_next) - if (s->compare_func(e->data, p)) + if (s->compare_func(e->data, p) == 0) return e; return NULL; @@ -278,7 +280,7 @@ void* idxset_remove_by_data(struct idxset*s, void *data, uint32_t *index) { } void* idxset_rrobin(struct idxset *s, uint32_t *index) { - assert(s && index); + assert(s); if (s->rrobin) s->rrobin = s->rrobin->iterate_next; -- cgit