#include "hash.h"
-#define TABLE_SIZE 1024 /**< Size of lookup table/array */
+#define TABLE_SIZE 1023 /**< Size of lookup table/array */
+
+#define HASH_FUNC(K) ((K) % TABLE_SIZE)
+
/**
* An entry in the hash table.
assert(table);
assert(key);
- pos = key & (TABLE_SIZE-1);
+ pos = HASH_FUNC(key);
entry = table->Table[pos];
while (entry) {
if (entry->Key == key) {
if (key > table->MaxKey)
table->MaxKey = key;
- pos = key & (TABLE_SIZE-1);
+ pos = HASH_FUNC(key);
entry = table->Table[pos];
while (entry) {
if (entry->Key == key) {
_glthread_LOCK_MUTEX(table->Mutex);
- pos = key & (TABLE_SIZE-1);
+ pos = HASH_FUNC(key);
prev = NULL;
entry = table->Table[pos];
while (entry) {
assert(key);
/* Find the entry with given key */
- pos = key & (TABLE_SIZE - 1);
+ pos = HASH_FUNC(key);
entry = table->Table[pos];
while (entry) {
if (entry->Key == key) {