mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	merge 'lennart' branch back into trunk.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									6687dd0131
								
							
						
					
					
						commit
						a67c21f093
					
				
					 294 changed files with 79057 additions and 11614 deletions
				
			
		| 
						 | 
				
			
			@ -26,13 +26,14 @@
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include <pulse/xmalloc.h>
 | 
			
		||||
 | 
			
		||||
#include <pulsecore/idxset.h>
 | 
			
		||||
#include <pulsecore/log.h>
 | 
			
		||||
#include <pulsecore/flist.h>
 | 
			
		||||
#include <pulsecore/macro.h>
 | 
			
		||||
 | 
			
		||||
#include "hashmap.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -55,6 +56,8 @@ struct pa_hashmap {
 | 
			
		|||
    pa_compare_func_t compare_func;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
PA_STATIC_FLIST_DECLARE(entries, 0, pa_xfree);
 | 
			
		||||
 | 
			
		||||
pa_hashmap *pa_hashmap_new(pa_hash_func_t hash_func, pa_compare_func_t compare_func) {
 | 
			
		||||
    pa_hashmap *h;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -69,8 +72,8 @@ pa_hashmap *pa_hashmap_new(pa_hash_func_t hash_func, pa_compare_func_t compare_f
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void remove(pa_hashmap *h, struct hashmap_entry *e) {
 | 
			
		||||
    assert(h);
 | 
			
		||||
    assert(e);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
    pa_assert(e);
 | 
			
		||||
 | 
			
		||||
    if (e->next)
 | 
			
		||||
        e->next->previous = e->previous;
 | 
			
		||||
| 
						 | 
				
			
			@ -84,16 +87,18 @@ static void remove(pa_hashmap *h, struct hashmap_entry *e) {
 | 
			
		|||
    if (e->bucket_previous)
 | 
			
		||||
        e->bucket_previous->bucket_next = e->bucket_next;
 | 
			
		||||
    else {
 | 
			
		||||
        assert(e->hash < h->size);
 | 
			
		||||
        pa_assert(e->hash < h->size);
 | 
			
		||||
        h->data[e->hash] = e->bucket_next;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pa_xfree(e);
 | 
			
		||||
    if (pa_flist_push(PA_STATIC_FLIST_GET(entries), e) < 0)
 | 
			
		||||
        pa_xfree(e);
 | 
			
		||||
 | 
			
		||||
    h->n_entries--;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pa_hashmap_free(pa_hashmap*h, void (*free_func)(void *p, void *userdata), void *userdata) {
 | 
			
		||||
    assert(h);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
 | 
			
		||||
    while (h->first_entry) {
 | 
			
		||||
        if (free_func)
 | 
			
		||||
| 
						 | 
				
			
			@ -107,8 +112,8 @@ void pa_hashmap_free(pa_hashmap*h, void (*free_func)(void *p, void *userdata), v
 | 
			
		|||
 | 
			
		||||
static struct hashmap_entry *get(pa_hashmap *h, unsigned hash, const void *key) {
 | 
			
		||||
    struct hashmap_entry *e;
 | 
			
		||||
    assert(h);
 | 
			
		||||
    assert(hash < h->size);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
    pa_assert(hash < h->size);
 | 
			
		||||
 | 
			
		||||
    for (e = h->data[hash]; e; e = e->bucket_next)
 | 
			
		||||
        if (h->compare_func(e->key, key) == 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -120,14 +125,16 @@ static struct hashmap_entry *get(pa_hashmap *h, unsigned hash, const void *key)
 | 
			
		|||
int pa_hashmap_put(pa_hashmap *h, const void *key, void *value) {
 | 
			
		||||
    struct hashmap_entry *e;
 | 
			
		||||
    unsigned hash;
 | 
			
		||||
    assert(h);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
 | 
			
		||||
    hash = h->hash_func(key) % h->size;
 | 
			
		||||
 | 
			
		||||
    if ((e = get(h, hash, key)))
 | 
			
		||||
        return -1;
 | 
			
		||||
 | 
			
		||||
    e = pa_xnew(struct hashmap_entry, 1);
 | 
			
		||||
    if (!(e = pa_flist_pop(PA_STATIC_FLIST_GET(entries))))
 | 
			
		||||
        e = pa_xnew(struct hashmap_entry, 1);
 | 
			
		||||
 | 
			
		||||
    e->hash = hash;
 | 
			
		||||
    e->key = key;
 | 
			
		||||
    e->value = value;
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +159,7 @@ void* pa_hashmap_get(pa_hashmap *h, const void *key) {
 | 
			
		|||
    unsigned hash;
 | 
			
		||||
    struct hashmap_entry *e;
 | 
			
		||||
 | 
			
		||||
    assert(h);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
 | 
			
		||||
    hash = h->hash_func(key) % h->size;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -167,7 +174,7 @@ void* pa_hashmap_remove(pa_hashmap *h, const void *key) {
 | 
			
		|||
    unsigned hash;
 | 
			
		||||
    void *data;
 | 
			
		||||
 | 
			
		||||
    assert(h);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
 | 
			
		||||
    hash = h->hash_func(key) % h->size;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -184,8 +191,8 @@ unsigned pa_hashmap_size(pa_hashmap *h) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void **key) {
 | 
			
		||||
    assert(h);
 | 
			
		||||
    assert(state);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
    pa_assert(state);
 | 
			
		||||
 | 
			
		||||
    if (!*state)
 | 
			
		||||
        *state = h->first_entry;
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +214,7 @@ void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void **key) {
 | 
			
		|||
void* pa_hashmap_steal_first(pa_hashmap *h) {
 | 
			
		||||
    void *data;
 | 
			
		||||
 | 
			
		||||
    assert(h);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
 | 
			
		||||
    if (!h->first_entry)
 | 
			
		||||
        return NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -218,7 +225,7 @@ void* pa_hashmap_steal_first(pa_hashmap *h) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
void *pa_hashmap_get_first(pa_hashmap *h) {
 | 
			
		||||
    assert(h);
 | 
			
		||||
    pa_assert(h);
 | 
			
		||||
 | 
			
		||||
    if (!h->first_entry)
 | 
			
		||||
        return NULL;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue