diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-09-02 12:07:44 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-09-02 22:41:58 +0200 |
commit | 9e90ff0839a2ad750faad0d8176cd7cc01c1dae2 (patch) | |
tree | c952a9703e63631fbb8c81250c96888b39da3f5b /lib/hash.c | |
parent | 9b3f888a00fe0c796e8ef7f00d03bb2adc2baa4e (diff) | |
download | curl-9e90ff0839a2ad750faad0d8176cd7cc01c1dae2.tar.gz |
hash: make it 'struct Curl_hash'
As internal global names should use captical C.
Closes #5906
Diffstat (limited to 'lib/hash.c')
-rw-r--r-- | lib/hash.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/hash.c b/lib/hash.c index 6d2fbf0db..8c1f6cd0a 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -34,8 +34,8 @@ static void hash_element_dtor(void *user, void *element) { - struct curl_hash *h = (struct curl_hash *) user; - struct curl_hash_element *e = (struct curl_hash_element *) element; + struct Curl_hash *h = (struct Curl_hash *) user; + struct Curl_hash_element *e = (struct Curl_hash_element *) element; if(e->ptr) { h->dtor(e->ptr); @@ -54,11 +54,11 @@ hash_element_dtor(void *user, void *element) * @unittest: 1603 */ int -Curl_hash_init(struct curl_hash *h, +Curl_hash_init(struct Curl_hash *h, int slots, hash_function hfunc, comp_function comparator, - curl_hash_dtor dtor) + Curl_hash_dtor dtor) { if(!slots || !hfunc || !comparator ||!dtor) { return 1; /* failure */ @@ -81,11 +81,11 @@ Curl_hash_init(struct curl_hash *h, return 1; /* failure */ } -static struct curl_hash_element * +static struct Curl_hash_element * mk_hash_element(const void *key, size_t key_len, const void *p) { /* allocate the struct plus memory after it to store the key */ - struct curl_hash_element *he = malloc(sizeof(struct curl_hash_element) + + struct Curl_hash_element *he = malloc(sizeof(struct Curl_hash_element) + key_len); if(he) { /* copy the key */ @@ -106,14 +106,14 @@ mk_hash_element(const void *key, size_t key_len, const void *p) * @unittest: 1603 */ void * -Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) +Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p) { - struct curl_hash_element *he; + struct Curl_hash_element *he; struct Curl_llist_element *le; struct Curl_llist *l = FETCH_LIST(h, key, key_len); for(le = l->head; le; le = le->next) { - he = (struct curl_hash_element *) le->ptr; + he = (struct Curl_hash_element *) le->ptr; if(h->comp_func(he->key, he->key_len, key, key_len)) { Curl_llist_remove(l, le, (void *)h); --h->size; @@ -136,13 +136,13 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) * * @unittest: 1603 */ -int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len) +int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len) { struct Curl_llist_element *le; struct Curl_llist *l = FETCH_LIST(h, key, key_len); for(le = l->head; le; le = le->next) { - struct curl_hash_element *he = le->ptr; + struct Curl_hash_element *he = le->ptr; if(h->comp_func(he->key, he->key_len, key, key_len)) { Curl_llist_remove(l, le, (void *) h); --h->size; @@ -157,7 +157,7 @@ int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len) * @unittest: 1603 */ void * -Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len) +Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len) { struct Curl_llist_element *le; struct Curl_llist *l; @@ -165,7 +165,7 @@ Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len) if(h) { l = FETCH_LIST(h, key, key_len); for(le = l->head; le; le = le->next) { - struct curl_hash_element *he = le->ptr; + struct Curl_hash_element *he = le->ptr; if(h->comp_func(he->key, he->key_len, key, key_len)) { return he->ptr; } @@ -177,7 +177,7 @@ Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len) #if defined(DEBUGBUILD) && defined(AGGRESIVE_TEST) void -Curl_hash_apply(curl_hash *h, void *user, +Curl_hash_apply(Curl_hash *h, void *user, void (*cb)(void *user, void *ptr)) { struct Curl_llist_element *le; @@ -187,7 +187,7 @@ Curl_hash_apply(curl_hash *h, void *user, for(le = (h->table[i])->head; le; le = le->next) { - curl_hash_element *el = le->ptr; + Curl_hash_element *el = le->ptr; cb(user, el->ptr); } } @@ -202,7 +202,7 @@ Curl_hash_apply(curl_hash *h, void *user, * @unittest: 1603 */ void -Curl_hash_destroy(struct curl_hash *h) +Curl_hash_destroy(struct Curl_hash *h) { int i; @@ -220,14 +220,14 @@ Curl_hash_destroy(struct curl_hash *h) * @unittest: 1602 */ void -Curl_hash_clean(struct curl_hash *h) +Curl_hash_clean(struct Curl_hash *h) { Curl_hash_clean_with_criterium(h, NULL, NULL); } /* Cleans all entries that pass the comp function criteria. */ void -Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, +Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user, int (*comp)(void *, void *)) { struct Curl_llist_element *le; @@ -242,7 +242,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user, list = &h->table[i]; le = list->head; /* get first list entry */ while(le) { - struct curl_hash_element *he = le->ptr; + struct Curl_hash_element *he = le->ptr; lnext = le->next; /* ask the callback function if we shall remove this entry or not */ if(comp == NULL || comp(user, he->ptr)) { @@ -277,18 +277,18 @@ size_t Curl_str_key_compare(void *k1, size_t key1_len, return 0; } -void Curl_hash_start_iterate(struct curl_hash *hash, - struct curl_hash_iterator *iter) +void Curl_hash_start_iterate(struct Curl_hash *hash, + struct Curl_hash_iterator *iter) { iter->hash = hash; iter->slot_index = 0; iter->current_element = NULL; } -struct curl_hash_element * -Curl_hash_next_element(struct curl_hash_iterator *iter) +struct Curl_hash_element * +Curl_hash_next_element(struct Curl_hash_iterator *iter) { - struct curl_hash *h = iter->hash; + struct Curl_hash *h = iter->hash; /* Get the next element in the current list, if any */ if(iter->current_element) @@ -307,7 +307,7 @@ Curl_hash_next_element(struct curl_hash_iterator *iter) } if(iter->current_element) { - struct curl_hash_element *he = iter->current_element->ptr; + struct Curl_hash_element *he = iter->current_element->ptr; return he; } iter->current_element = NULL; @@ -315,11 +315,11 @@ Curl_hash_next_element(struct curl_hash_iterator *iter) } #if 0 /* useful function for debugging hashes and their contents */ -void Curl_hash_print(struct curl_hash *h, +void Curl_hash_print(struct Curl_hash *h, void (*func)(void *)) { - struct curl_hash_iterator iter; - struct curl_hash_element *he; + struct Curl_hash_iterator iter; + struct Curl_hash_element *he; int last_index = -1; if(!h) |