65 if(!slots || !hfunc || !comparator ||!dtor) {
100 #define FETCH_LIST(x,y,z) &x->table[x->hash_func(y, z, x->slots)] 116 for(le = l->
head; le; le = le->
next) {
146 for(le = l->
head; le; le = le->
next) {
170 for(le = l->
head; le; le = le->
next) {
181 #if defined(DEBUGBUILD) && defined(AGGRESIVE_TEST) 184 void (*
cb)(
void *user,
void *
ptr))
189 for(i = 0; i < h->
slots; ++
i) {
190 for(le = (h->
table[i])->head;
212 for(i = 0; i < h->
slots; ++
i) {
234 int (*comp)(
void *,
void *))
244 for(i = 0; i < h->
slots; ++
i) {
251 if(comp == NULL || comp(user, he->
ptr)) {
262 const char *key_str = (
const char *) key;
263 const char *end = key_str + key_length;
264 unsigned long h = 5381;
266 while(key_str < end) {
268 h ^= (
unsigned long) *key_str++;
271 return (h % slots_num);
275 void *k2,
size_t key2_len)
277 if((key1_len == key2_len) && !memcmp(k1, k2, key1_len))
322 void (*func)(
void *))
331 fprintf(stderr,
"=Hash dump=\n");
339 if(last_index >= 0) {
int Curl_hash_init(struct curl_hash *h, int slots, hash_function hfunc, comp_function comparator, curl_hash_dtor dtor)
void(* curl_llist_dtor)(void *, void *)
void Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, int(*comp)(void *, void *))
void Curl_hash_apply(struct curl_hash *h, void *user, void(*cb)(void *user, void *ptr))
int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
struct curl_llist_element * tail
UNITTEST_START char * ptr
void(* curl_hash_dtor)(void *)
void Curl_llist_init(struct curl_llist *l, curl_llist_dtor dtor)
void Curl_hash_destroy(struct curl_hash *h)
void Curl_hash_clean(struct curl_hash *h)
void Curl_hash_start_iterate(struct curl_hash *hash, struct curl_hash_iterator *iter)
memcpy(filename, filename1, strlen(filename1))
struct curl_llist_element * current_element
static struct curl_hash_element * mk_hash_element(const void *key, size_t key_len, const void *p)
void Curl_hash_print(struct curl_hash *h, void(*func)(void *))
static void hash_element_dtor(void *user, void *element)
size_t Curl_str_key_compare(void *k1, size_t key1_len, void *k2, size_t key2_len)
size_t(* hash_function)(void *key, size_t key_length, size_t slots_num)
struct curl_llist_element * head
#define Curl_safefree(ptr)
void Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e, void *user)
size_t(* comp_function)(void *key1, size_t key1_len, void *key2, size_t key2_len)
static size_t cb(char *d, size_t n, size_t l, void *p)
void Curl_llist_destroy(struct curl_llist *list, void *user)
#define FETCH_LIST(x, y, z)
size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num)
void * Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
void Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e, const void *p, struct curl_llist_element *ne)
struct curl_hash_element * Curl_hash_next_element(struct curl_hash_iterator *iter)
struct curl_llist_element list
struct curl_llist * table
void * Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
struct curl_llist_element * next