1
0
mirror of https://github.com/moparisthebest/curl synced 2025-02-28 09:21:50 -05:00

hash: calculate sizes with size_t instead of longs

... since they return size_t anyway!

closes #2462
This commit is contained in:
Daniel Stenberg 2018-04-06 14:19:39 +02:00
parent 67bd4ab19e
commit dd03e8c281
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 5 additions and 5 deletions

View File

@ -270,11 +270,11 @@ static const char *get_top_domain(const char * const domain, size_t *outlen)
static size_t cookie_hash_domain(const char *domain, const size_t len)
{
const char *end = domain + len;
unsigned long h = 5381;
size_t h = 5381;
while(domain < end) {
h += h << 5;
h ^= (unsigned long) Curl_raw_toupper(*domain++);
h ^= Curl_raw_toupper(*domain++);
}
return (h % COOKIE_HASH_SIZE);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -261,11 +261,11 @@ size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num)
{
const char *key_str = (const char *) key;
const char *end = key_str + key_length;
unsigned long h = 5381;
size_t h = 5381;
while(key_str < end) {
h += h << 5;
h ^= (unsigned long) *key_str++;
h ^= *key_str++;
}
return (h % slots_num);