39 hash_str(
const char *key,
size_t key_length)
41 char *
end = (
char *) key + key_length;
42 unsigned long h = 5381;
46 h ^= (
unsigned long) *key++;
53 hash_element_dtor(
void *user,
void *element)
79 for (i = 0; i < slots; ++
i) {
112 hash_key_compare(
char *key1,
size_t key1_len,
char *key2,
size_t key2_len)
114 if (key1_len == key2_len &&
116 memcmp(key1, key2, key1_len) == 0) {
124 mk_hash_element(
char *key,
size_t key_len,
const void *
p)
132 he->
ptr = (
void *) p;
137 #define find_slot(__h, __k, __k_len) (hash_str(__k, __k_len) % (__h)->slots)
139 #define FETCH_LIST(x,y,z) x->table[find_slot(x, y, z)]
150 for (le = l->
head; le; le = le->
next) {
152 if (hash_key_compare(he->
key, he->
key_len, key, key_len)) {
158 he = mk_hash_element(key, key_len, p);
165 hash_element_dtor(h, he);
183 if (hash_key_compare(he->
key, he->
key_len, key, key_len)) {
205 if (hash_key_compare(he->
key, he->
key_len, key, key_len)) {
213 #if defined(CURLDEBUG) && defined(AGGRESIVE_TEST)
216 void (*cb)(
void *user,
void *ptr))
221 for (i = 0; i < h->
slots; ++
i) {
222 for (le = (h->
table[i])->head;
237 for (i = 0; i < h->
slots; ++
i) {
246 int (*comp)(
void *,
void *))
253 for (i = 0; i < h->
slots; ++
i) {
260 if (comp(user, he->
ptr)) {
void Curl_hash_apply(curl_hash *h, void *user, void(*cb)(void *user, void *ptr))
int Curl_hash_delete(curl_hash *h, char *key, size_t key_len)
curl_llist_element * tail
void * Curl_hash_pick(curl_hash *h, char *key, size_t key_len)
curl_llist_element * head
curl_hash * Curl_hash_alloc(int slots, curl_hash_dtor dtor)
int Curl_hash_count(curl_hash *h)
void Curl_hash_clean(curl_hash *h)
struct _curl_llist_element * next
void Curl_hash_clean_with_criterium(curl_hash *h, void *user, int(*comp)(void *, void *))
int Curl_llist_insert_next(curl_llist *list, curl_llist_element *e, const void *p)
int Curl_hash_init(curl_hash *h, int slots, curl_hash_dtor dtor)
void Curl_hash_destroy(curl_hash *h)
void Curl_llist_destroy(curl_llist *list, void *user)
void(* curl_llist_dtor)(void *, void *)
curl_llist * Curl_llist_alloc(curl_llist_dtor dtor)
#define FETCH_LIST(x, y, z)
void * Curl_hash_add(curl_hash *h, char *key, size_t key_len, void *p)
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
void(* curl_hash_dtor)(void *)
int Curl_llist_remove(curl_llist *list, curl_llist_element *e, void *user)