diff --git a/src/hash.c b/src/hash.c index 584c446..7f16b0b 100644 --- a/src/hash.c +++ b/src/hash.c @@ -1,7 +1,7 @@ #include "proxy.h" #include "libs/blake2.h" -static unsigned hashindex(struct hashtable *ht, const uint8_t* hash){ +static uint32_t hashindex(struct hashtable *ht, const uint8_t* hash){ return (*(unsigned *)hash ) % (ht->tablesize); } @@ -80,7 +80,7 @@ int inithashtable(struct hashtable *ht, unsigned nhashsize){ static void hashcompact(struct hashtable *ht){ int i; - int he, *hep; + uint32_t he, *hep; if((conf.time - ht->compacted) < 60 || !ht->tablesize || !ht->hashsize || ht->hashsize/ht->tablesize >= 4 ) return; for(i = 0; i < ht->tablesize; i++){ @@ -98,10 +98,10 @@ static void hashcompact(struct hashtable *ht){ } void hashadd(struct hashtable *ht, const void* name, const void* value, time_t expires){ - int hen, he; - int *hep; + uint32_t hen, he; + uint32_t *hep; - unsigned index; + uint32_t index; pthread_mutex_lock(&hash_mutex); if(!ht->ihashempty){ @@ -135,9 +135,9 @@ void hashadd(struct hashtable *ht, const void* name, const void* value, time_t e int hashresolv(struct hashtable *ht, const void* name, void* value, uint32_t *ttl){ uint8_t hash[HASH_SIZE]; - int *hep; - int he; - unsigned index; + uint32_t *hep; + uint32_t he; + uint32_t index; pthread_mutex_lock(&hash_mutex); if(!ht || !ht->ihashtable || !name) { diff --git a/src/structures.h b/src/structures.h index 0ffbb5c..3fae967 100644 --- a/src/structures.h +++ b/src/structures.h @@ -759,7 +759,7 @@ struct child { struct hashentry { uint8_t hash[HASH_SIZE]; time_t expires; - int inext; + uint32_t inext; char value[4]; }; @@ -767,9 +767,9 @@ struct hashtable { unsigned hashsize; unsigned recsize; unsigned rnd[4]; - int * ihashtable; + uint32_t * ihashtable; uint8_t * hashvalues; - int ihashempty; + uint32_t ihashempty; void (*index2hash)(const void *index, unsigned char *hash, const unsigned char *rnd); int grow; time_t compacted;