/**
* Returns the hash code of a string.
*/
-unsigned int xbt_dict_hash(const char *str) {
+static unsigned int xbt_dict_hash(const char *str, int str_len) {
/* fast implementation of djb2 algorithm */
unsigned int hash = 5381;
int c;
- while ((c = *str++)) {
+ while (str_len--) {
+ c = *str++;
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
}
void_f_pvoid_t *free_ctn) {
xbt_assert(dict);
- unsigned int hash_code = xbt_dict_hash(key) % dict->table_size;
+ unsigned int hash_code = xbt_dict_hash(key,key_len) % dict->table_size;
xbt_dictelm_t current, previous = NULL;
current = dict->table[hash_code];
int key_len) {
xbt_assert(dict);
- unsigned int hash_code = xbt_dict_hash(key) % dict->table_size;
+ unsigned int hash_code = xbt_dict_hash(key,key_len) % dict->table_size;
xbt_dictelm_t current;
current = dict->table[hash_code];
int key_len) {
xbt_assert(dict);
- unsigned int hash_code = xbt_dict_hash(key) % dict->table_size;
+ unsigned int hash_code = xbt_dict_hash(key,key_len) % dict->table_size;
xbt_dictelm_t current, previous = NULL;
current = dict->table[hash_code];
void xbt_dict_add_element(xbt_dict_t dict, xbt_dictelm_t element) {
xbt_assert(dict);
- int hashcode = xbt_dict_hash(element->key) % dict->table_size;
+ int hashcode = xbt_dict_hash(element->key,element->key_len) % dict->table_size;
element->next = dict->table[hashcode];
dict->table[hashcode] = element;
}