Skip to content

Commit

Permalink
lib: bump hash sizes to size_t
Browse files Browse the repository at this point in the history
Follow-up to cc907e8 curl#13502
Cherry-picked from curl#13489
Closes curl#13601
  • Loading branch information
vszakats committed May 12, 2024
1 parent 25cbc2f commit a35bbe8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/conncache.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void free_bundle_hash_entry(void *freethis)
bundle_destroy(b);
}

int Curl_conncache_init(struct conncache *connc, int size)
int Curl_conncache_init(struct conncache *connc, size_t size)
{
/* allocate a new easy handle to use when closing cached connections */
connc->closure_handle = curl_easy_init();
Expand Down
2 changes: 1 addition & 1 deletion lib/conncache.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct connectbundle {
};

/* returns 1 on error, 0 is fine */
int Curl_conncache_init(struct conncache *, int size);
int Curl_conncache_init(struct conncache *, size_t size);
void Curl_conncache_destroy(struct conncache *connc);

/* return the correct bundle, to a host or a proxy */
Expand Down
2 changes: 1 addition & 1 deletion lib/hostip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ static void freednsentry(void *freethis)
/*
* Curl_init_dnscache() inits a new DNS cache.
*/
void Curl_init_dnscache(struct Curl_hash *hash, int size)
void Curl_init_dnscache(struct Curl_hash *hash, size_t size)
{
Curl_hash_init(hash, size, Curl_hash_str, Curl_str_key_compare,
freednsentry);
Expand Down
2 changes: 1 addition & 1 deletion lib/hostip.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void Curl_resolv_unlock(struct Curl_easy *data,
struct Curl_dns_entry *dns);

/* init a new dns cache */
void Curl_init_dnscache(struct Curl_hash *hash, int hashsize);
void Curl_init_dnscache(struct Curl_hash *hash, size_t hashsize);

/* prune old entries from the DNS cache */
void Curl_hostcache_prune(struct Curl_easy *data);
Expand Down
8 changes: 4 additions & 4 deletions lib/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ static size_t hash_fd(void *key, size_t key_length, size_t slots_num)
* per call."
*
*/
static void sh_init(struct Curl_hash *hash, int hashsize)
static void sh_init(struct Curl_hash *hash, size_t hashsize)
{
Curl_hash_init(hash, hashsize, hash_fd, fd_key_compare,
sh_freeentry);
Expand All @@ -381,9 +381,9 @@ static void multi_addmsg(struct Curl_multi *multi, struct Curl_message *msg)
Curl_llist_append(&multi->msglist, msg, &msg->list);
}

struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
int chashsize, /* connection hash */
int dnssize) /* dns hash */
struct Curl_multi *Curl_multi_handle(size_t hashsize, /* socket hash */
size_t chashsize, /* connection hash */
size_t dnssize) /* dns hash */
{
struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi));

Expand Down
5 changes: 3 additions & 2 deletions lib/multiif.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ void Curl_multi_connchanged(struct Curl_multi *multi);

/* Internal version of curl_multi_init() accepts size parameters for the
socket, connection and dns hashes */
struct Curl_multi *Curl_multi_handle(int hashsize, int chashsize,
int dnssize);
struct Curl_multi *Curl_multi_handle(size_t hashsize,
size_t chashsize,
size_t dnssize);

/* the write bits start at bit 16 for the *getsock() bitmap */
#define GETSOCK_WRITEBITSTART 16
Expand Down

0 comments on commit a35bbe8

Please sign in to comment.