mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-19 18:50:12 +08:00
Use uint32_t for hashtable indicies
This commit is contained in:
parent
bba9871ed8
commit
260cbf7a3d
16
src/hash.c
16
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) {
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user