- struct hashlistnode<_Key,_Val, _malloc, _calloc, _free> *ptr = table[(((_KeyInt)key) & mask)>>_Shift];
- struct hashlistnode<_Key,_Val, _malloc, _calloc, _free> *search = ptr;
-
- while(search!=NULL) {
- if (search->key==key) {
- search->val=val;
+ struct hashlistnode<_Key, _Val> *search;
+ struct hashlistnode<_Key, _Val> *first = NULL;
+
+ unsigned int index = hash_function(key) & capacitymask;
+ unsigned int oindex = index;
+ do {
+ search = &table[index];
+ if (!search->key) {
+ //key is null, probably done
+ if (!search->val)
+ break;
+ if (first == NULL)
+ first = search;
+ }
+ if (equals(search->key, key)) {
+ search->val = val;