Go to the documentation of this file.
233 ASSERT(start_bucket >= 0 && start_bucket <= end_bucket);
343 word_hash_function(
const void *
key, uint32_t iv)
345 const char *str = (
const char *)
key;
346 const int len = strlen(str);
347 return hash_func((
const uint8_t *)str, len, iv);
351 word_compare_function(
const void *
key1,
const void *
key2)
353 return strcmp((
const char *)
key1, (
const char *)
key2) == 0;
367 printf(
"%d ", (
int) he->
value);
377 rmhash(
struct hash *
hash,
const char *word)
385 openvpn_thread_init();
403 if (!fgets(buf,
sizeof(buf), stdin))
412 if (isalnum(c) || c ==
'_')
414 ASSERT(wbi < (
int)
sizeof(wordbuf));
422 ASSERT(wbi < (
int)
sizeof(wordbuf));
423 wordbuf[wbi++] =
'\0';
453 rmhash(
hash,
"true");
454 rmhash(
hash,
"false");
473 struct word *w = (
struct word *) he->
value;
474 printf(
"%6d '%s'\n", w->n, w->word);
487 for (i = 1; i <= 16; ++i)
489 printf(
"[%d] ***********************************\n", i);
493 printf(
"FINAL **************************\n");
503 openvpn_thread_cleanup();
573 #define mix(a, b, c) \
575 a -= b; a -= c; a ^= (c>>13); \
576 b -= c; b -= a; b ^= (a<<8); \
577 c -= a; c -= b; c ^= (b>>13); \
578 a -= b; a -= c; a ^= (c>>12); \
579 b -= c; b -= a; b ^= (a<<16); \
580 c -= a; c -= b; c ^= (b>>5); \
581 a -= b; a -= c; a ^= (c>>3); \
582 b -= c; b -= a; b ^= (a<<10); \
583 c -= a; c -= b; c ^= (b>>15); \
587 hash_func(
const uint8_t *k, uint32_t length, uint32_t initval)
589 uint32_t a, b, c, len;
599 a += (k[0] + ((uint32_t) k[1] << 8)
600 + ((uint32_t) k[2] << 16)
601 + ((uint32_t) k[3] << 24));
602 b += (k[4] + ((uint32_t) k[5] << 8)
603 + ((uint32_t) k[6] << 16)
604 + ((uint32_t) k[7] << 24));
605 c += (k[8] + ((uint32_t) k[9] << 8)
606 + ((uint32_t) k[10] << 16)
607 + ((uint32_t) k[11] << 24));
618 c += ((uint32_t) k[10] << 24);
621 c += ((uint32_t) k[9] << 16);
624 c += ((uint32_t) k[8] << 8);
628 b += ((uint32_t) k[7] << 24);
631 b += ((uint32_t) k[6] << 16);
634 b += ((uint32_t) k[5] << 8);
640 a += ((uint32_t) k[3] << 24);
643 a += ((uint32_t) k[2] << 16);
646 a += ((uint32_t) k[1] << 8);
static int hash_n_elements(const struct hash *hash)
struct hash * hash_init(const int n_buckets, const uint32_t iv, uint32_t(*hash_function)(const void *key, uint32_t iv), bool(*compare_function)(const void *key1, const void *key2))
static struct gc_arena gc_new(void)
struct hash_element * next
static const char *const key1
long int get_random(void)
bool hash_add(struct hash *hash, const void *key, void *value, bool replace)
static bool hash_remove(struct hash *hash, const void *key)
static void * hash_lookup(struct hash *hash, const void *key)
struct hash_bucket * buckets
static void hash_iterator_lock(struct hash_iterator *hi, struct hash_bucket *b)
Container for unidirectional cipher and HMAC key material.
void hash_remove_by_value(struct hash *hash, void *value)
void hash_iterator_free(struct hash_iterator *hi)
char * string_alloc(const char *str, struct gc_arena *gc)
uint32_t(* hash_function)(const void *key, uint32_t iv)
struct hash_element * hash_iterator_next(struct hash_iterator *hi)
static void hash_add_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv, void *value)
struct hash_element * list
struct hash_element * hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv)
struct hash_element * elem
static size_t adjust_power_of_2(size_t u)
void hash_iterator_delete_element(struct hash_iterator *hi)
void hash_iterator_init(struct hash *hash, struct hash_iterator *hi)
Garbage collection arena used to keep track of dynamically allocated memory.
struct hash_bucket * bucket
static void hash_remove_marked(struct hash *hash, struct hash_bucket *bucket)
void hash_free(struct hash *hash)
static void hash_iterator_unlock(struct hash_iterator *hi)
bool hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv)
static void gc_free(struct gc_arena *a)
#define ALLOC_OBJ_CLEAR(dptr, type)
static void hash_iterator_advance(struct hash_iterator *hi)
Container for bidirectional cipher and HMAC key material.
static int hash_n_buckets(const struct hash *hash)
bool(* compare_function)(const void *key1, const void *key2)
struct hash_element * last
#define ALLOC_ARRAY(dptr, type, n)
uint32_t hash_func(const uint8_t *k, uint32_t length, uint32_t initval)
void hash_iterator_init_range(struct hash *hash, struct hash_iterator *hi, int start_bucket, int end_bucket)
#define ALLOC_OBJ_GC(dptr, type, gc)
static uint32_t hash_value(const struct hash *hash, const void *key)