ptr = mlookup.table;
mlookup.numelements++;
- index = mhashFunction(key);
#ifdef DEBUG
printf("DEBUG -> index = %d, key = %d, val = %x\n", index, key, val);
#endif
pthread_mutex_lock(&mlookup.locktable);
+ index = mhashFunction(key);
if(ptr[index].next == NULL && ptr[index].key == 0) { // Insert at the first position in the hashtable
ptr[index].key = key;
ptr[index].val = val;
int index;
mhashlistnode_t *ptr, *node;
+ pthread_mutex_lock(&mlookup.locktable);
ptr = mlookup.table; // Address of the beginning of hash table
index = mhashFunction(key);
node = &ptr[index];
- pthread_mutex_lock(&mlookup.locktable);
while(node != NULL) {
if(node->key == key) {
pthread_mutex_unlock(&mlookup.locktable);
mhashlistnode_t *curr, *prev;
mhashlistnode_t *ptr, *node;
+ pthread_mutex_lock(&mlookup.locktable);
ptr = mlookup.table;
index = mhashFunction(key);
curr = &ptr[index];
-
- pthread_mutex_lock(&mlookup.locktable);
for (; curr != NULL; curr = curr->next) {
if (curr->key == key) { // Find a match in the hash table
mlookup.numelements--; // Decrement the number of elements in the global hashtable