diff --git a/regressions/ck_ht/validate/serial.c b/regressions/ck_ht/validate/serial.c index fa3f874..9a85c2f 100644 --- a/regressions/ck_ht/validate/serial.c +++ b/regressions/ck_ht/validate/serial.c @@ -33,6 +33,9 @@ #include #include #include "../../common.h" +#include "../../../src/ck_ht_hash.h" + +static size_t hash_times_called = 0; static void * ht_malloc(size_t r) @@ -51,6 +54,18 @@ ht_free(void *p, size_t b, bool r) return; } +static void +ht_hash_wrapper(struct ck_ht_hash *h, + const void *key, + size_t length, + uint64_t seed) +{ + hash_times_called++; + + h->value = (unsigned long)MurmurHash64A(key, length, seed); + return; +} + static struct ck_malloc my_allocator = { .malloc = ht_malloc, .free = ht_free @@ -82,7 +97,7 @@ main(void) mode |= CK_HT_WORKLOAD_DELETE; #endif - if (ck_ht_init(&ht, mode, NULL, &my_allocator, 2, 6602834) == false) { + if (ck_ht_init(&ht, mode, ht_hash_wrapper, &my_allocator, 2, 6602834) == false) { perror("ck_ht_init"); exit(EXIT_FAILURE); } @@ -247,7 +262,14 @@ main(void) } ck_ht_destroy(&ht); - if (ck_ht_init(&ht, CK_HT_MODE_DIRECT, NULL, &my_allocator, 8, 6602834) == false) { + + if (hash_times_called == 0) { + ck_error("ERROR: Our hash function was not called!\n"); + } + + hash_times_called = 0; + + if (ck_ht_init(&ht, CK_HT_MODE_DIRECT, ht_hash_wrapper, &my_allocator, 8, 6602834) == false) { perror("ck_ht_init"); exit(EXIT_FAILURE); } @@ -278,5 +300,10 @@ main(void) } ck_ht_destroy(&ht); + + if (hash_times_called == 0) { + ck_error("ERROR: Our hash function was not called!\n"); + } + return 0; } diff --git a/src/ck_ht.c b/src/ck_ht.c index fdbfdcc..2c864c5 100644 --- a/src/ck_ht.c +++ b/src/ck_ht.c @@ -112,7 +112,7 @@ ck_ht_hash(struct ck_ht_hash *h, uint16_t key_length) { - h->value = MurmurHash64A(key, key_length, table->seed); + table->h(h, key, key_length, table->seed); return; }