* @param key The key for the new value; must not be 0 or NULL
* @param val The value to store in the table
*/
- void put(_Key key, _Val val) {
+ _Val put(_Key key, _Val val) {
/* Hashtable cannot handle 0 as a key */
if (!key) {
+ _Val oldval;
if (!zero) {
zero = (struct Hashlistnode<_Key, _Val> *)ourmalloc(sizeof(struct Hashlistnode<_Key, _Val>));
size++;
- }
+ oldval = (_Val) 0;
+ } else
+ oldval = zero->val;
zero->key = key;
zero->val = val;
- return;
+ return oldval;
}
if (size > threshold)
}
if (search->hashcode == hashcode)
if (equals(search->key, key)) {
+ _Val oldval = search->val;
search->val = val;
- return;
+ return oldval;
}
index++;
} while (true);
search->val = val;
search->hashcode = hashcode;
size++;
+ return (_Val) 0;
}
/**