1 #include "dict.h" 2 dict_get(dict * d,const str * s)3dict_entry* dict_get(dict* d, const str* s) 4 { 5 uint32 hash; 6 unsigned i; 7 dict_entry* slot; 8 if (!d->size || !d->table) return 0; 9 hash = dict_hashstr(s); 10 i = hash % d->size; 11 while ((slot = d->table[i]) != 0) { 12 if (hash == slot->hash) 13 if (str_diff(s, &slot->key) == 0) 14 return slot; 15 if (++i >= d->size) i = 0; 16 } 17 return 0; 18 } 19