*/
void
Curl_hash_init(struct Curl_hash *h,
- int slots,
+ size_t slots,
hash_function hfunc,
comp_function comparator,
Curl_hash_dtor dtor)
DEBUGASSERT(h);
DEBUGASSERT(h->slots);
if(!h->table) {
- int i;
+ size_t i;
h->table = malloc(h->slots * sizeof(struct Curl_llist));
if(!h->table)
return NULL; /* OOM */
void (*cb)(void *user, void *ptr))
{
struct Curl_llist_element *le;
- int i;
+ size_t i;
for(i = 0; i < h->slots; ++i) {
for(le = (h->table[i])->head;
Curl_hash_destroy(struct Curl_hash *h)
{
if(h->table) {
- int i;
+ size_t i;
for(i = 0; i < h->slots; ++i) {
Curl_llist_destroy(&h->table[i], (void *) h);
}
struct Curl_llist_element *le;
struct Curl_llist_element *lnext;
struct Curl_llist *list;
- int i;
+ size_t i;
if(!h || !h->table)
return;
/* If we have reached the end of the list, find the next one */
if(!iter->current_element) {
- int i;
+ size_t i;
for(i = iter->slot_index; i < h->slots; i++) {
if(h->table[i].head) {
iter->current_element = h->table[i].head;
{
struct Curl_hash_iterator iter;
struct Curl_hash_element *he;
- int last_index = -1;
+ size_t last_index = ~0;
if(!h)
return;
while(he) {
if(iter.slot_index != last_index) {
fprintf(stderr, "index %d:", iter.slot_index);
- if(last_index >= 0) {
+ if(last_index != ~0) {
fprintf(stderr, "\n");
}
last_index = iter.slot_index;
#endif
void Curl_hash_offt_init(struct Curl_hash *h,
- unsigned int slots,
+ size_t slots,
Curl_hash_dtor dtor)
{
Curl_hash_init(h, slots, Curl_hash_str, Curl_str_key_compare, dtor);
/* Comparator function to compare keys */
comp_function comp_func;
Curl_hash_dtor dtor;
- int slots;
+ size_t slots;
size_t size;
};
struct Curl_hash_iterator {
struct Curl_hash *hash;
- int slot_index;
+ size_t slot_index;
struct Curl_llist_element *current_element;
};
void Curl_hash_init(struct Curl_hash *h,
- int slots,
+ size_t slots,
hash_function hfunc,
comp_function comparator,
Curl_hash_dtor dtor);
void (*func)(void *));
/* Hash for `curl_off_t` as key */
-void Curl_hash_offt_init(struct Curl_hash *h,
- unsigned int slots,
+void Curl_hash_offt_init(struct Curl_hash *h, size_t slots,
Curl_hash_dtor dtor);
void *Curl_hash_offt_set(struct Curl_hash *h, curl_off_t id, void *elem);