mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Sync changes
This commit is contained in:
parent
b8ed157105
commit
a551a8a219
1 changed files with 16 additions and 10 deletions
|
@ -58,15 +58,18 @@ void *ck_hs_get(ck_hs_t *_hs, unsigned long hash, const void *key)
|
||||||
bool ck_hs_put(ck_hs_t *_hs, unsigned long hash, const void *key)
|
bool ck_hs_put(ck_hs_t *_hs, unsigned long hash, const void *key)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int rv;
|
int rv, index;
|
||||||
simple_hashset_t hs = (*_hs).hs;
|
simple_hashset_t hs = (*_hs).hs;
|
||||||
|
|
||||||
pthread_mutex_lock(&((*_hs).lock));
|
pthread_mutex_lock(&((*_hs).lock));
|
||||||
|
|
||||||
|
//index = simple_hashset_is_member(hs, (symbol_type *)key);
|
||||||
|
//if (index == 0) {
|
||||||
rv = simple_hashset_add(hs, (symbol_type *)key);
|
rv = simple_hashset_add(hs, (symbol_type *)key);
|
||||||
if (rv >= 0) {
|
if (rv >= 0) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
|
|
||||||
pthread_mutex_unlock(&((*_hs).lock));
|
pthread_mutex_unlock(&((*_hs).lock));
|
||||||
return result;
|
return result;
|
||||||
|
@ -253,11 +256,14 @@ void ck_pr_store_ptr(void *target, void *value)
|
||||||
static const size_t prime_1 = 73;
|
static const size_t prime_1 = 73;
|
||||||
static const size_t prime_2 = 5009;
|
static const size_t prime_2 = 5009;
|
||||||
|
|
||||||
size_t hash_function(const char* p, size_t len)
|
size_t hash_function(const char* str, size_t len) {
|
||||||
{
|
unsigned long hash = 5381;
|
||||||
size_t hash = 0;
|
int c;
|
||||||
for (; *p; ++p)
|
|
||||||
hash ^= *p + 0x9e3779b9 + (hash << 6) + (hash >> 2);
|
while (c = *str++) {
|
||||||
|
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
||||||
|
}
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue