hash: change 'slots' to size_t from int

- an unsigned type makes more sense
- size_t seems suitable
- on 64 bit args, the struct alignment makes the new Curl_hash remain
  the same size

Closes #13502
This commit is contained in:
Daniel Stenberg 2024-04-30 08:46:54 +02:00
parent 602fc213ae
commit cc907e80a2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 13 additions and 14 deletions

View file

@ -54,7 +54,7 @@ struct Curl_hash {
/* Comparator function to compare keys */
comp_function comp_func;
Curl_hash_dtor dtor;
int slots;
size_t slots;
size_t size;
};
@ -67,12 +67,12 @@ struct Curl_hash_element {
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);
@ -99,8 +99,7 @@ void Curl_hash_print(struct Curl_hash *h,
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);