Lines Matching refs:key

40  * 	- Destructor functions for the key and value being hashed.
45 * destructor is needed for either a key or value.
50 * key) to the hashing function is a void * that represents
58 * - A key comparator (a la qsort).
59 * This is used when searching the hash chain. The key comparator
84 * destroy the given hash table, calling the key and value destructors
85 * on each key-value pair stored in the hash.
87 * mod_hash_insert(hash, key, val):
88 * place a key, value pair into the given hash.
91 * mod_hash_insert_reserve(hash, key, val, handle):
92 * place a key, value pair into the given hash, using handle to indicate
97 * reserve storage for a key-value pair using the memory allocation
100 * mod_hash_reserve_nosleep(hash, *handle): reserve storage for a key-value
104 * mod_hash_remove(hash, key, *val):
105 * remove a key-value pair with key 'key' from 'hash', destroying the
106 * stored key, and returning the value in val.
108 * mod_hash_replace(hash, key, val)
109 * atomically remove an existing key-value pair from a hash, and replace
110 * the key and value with the ones supplied. The removed key and value
113 * mod_hash_destroy(hash, key):
114 * remove a key-value pair with key 'key' from 'hash', destroying both
115 * stored key and stored value.
117 * mod_hash_find(hash, key, val):
118 * find a value in the hash table corresponding to the given key.
120 * mod_hash_find_cb(hash, key, val, found_callback)
121 * find a value in the hash table corresponding to the given key.
122 * If a value is found, call specified callback passing key and val to it.
127 * mod_hash_walk(hash, callback(key, elem, arg), arg)
129 * function with the key/value pair for each element. the hashtable
136 * clears the given hash table of entries, calling the key and value
149 * Invoke the key destructor.
151 #define MH_KEY_DESTROY(hash, key) ((hash->mh_kdtor)(key))
161 * Call the key comparator for the given hash keys.
175 * no-op key and value destructors.
179 mod_hash_null_keydtor(mod_hash_key_t key)
194 * Hash and key comparison routines for hashes with string keys.
205 mod_hash_bystr(void *hash_data, mod_hash_key_t key)
209 char *p, *k = (char *)key;
229 mod_hash_strkey_dtor(mod_hash_key_t key)
231 char *c = (char *)key;
261 * Hash and key comparison routines for hashes with pointer keys.
271 mod_hash_byptr(void *hash_data, mod_hash_key_t key)
273 uintptr_t k = (uintptr_t)key;
326 * Hash and key comparison routines for hashes with 32-bit unsigned keys.
336 * slots. The hash index is then this number times the key modulo
337 * the hash size, or (key * prime) % nchains.
340 mod_hash_byid(void *hash_data, mod_hash_key_t key)
343 return ((uint_t)(uintptr_t)key * (uint_t)kval);
429 void (*kdtor)(mod_hash_key_t), /* key destructor */
433 int (*keycmp)(mod_hash_key_t, mod_hash_key_t), /* key comparator */
515 * Call the hashing algorithm for this hash table, with the given key.
518 i_mod_hash(mod_hash_t *hash, mod_hash_key_t key)
528 h = (hash->mh_hashalg)(hash->mh_hashalg_data, key);
536 * insert 'val' into the hash table, using 'key' as its key. If 'key' is
537 * already a key in the hash, an error will be returned, and the key-val
545 i_mod_hash_insert_nosync(mod_hash_t *hash, mod_hash_key_t key,
567 hashidx = i_mod_hash(hash, key);
568 entry->mhe_key = key;
579 mod_hash_insert(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t val)
589 if (i_mod_hash_find_nosync(hash, key, &v) == 0) {
595 res = i_mod_hash_insert_nosync(hash, key, val, (mod_hash_hndl_t)0);
602 mod_hash_insert_reserve(mod_hash_t *hash, mod_hash_key_t key,
613 if (i_mod_hash_find_nosync(hash, key, &v) == 0) {
618 res = i_mod_hash_insert_nosync(hash, key, val, handle);
670 i_mod_hash_remove_nosync(mod_hash_t *hash, mod_hash_key_t key,
676 hashidx = i_mod_hash(hash, key);
680 if (MH_KEYCMP(hash, e->mhe_key, key) == 0)
695 * Clean up resources used by the node's key.
707 mod_hash_remove(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t *val)
712 res = i_mod_hash_remove_nosync(hash, key, val);
720 * atomically remove an existing key-value pair from a hash, and replace
721 * the key and value with the ones supplied. The removed key and value
725 mod_hash_replace(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t val)
732 if (i_mod_hash_remove_nosync(hash, key, &v) == 0) {
734 * mod_hash_remove() takes care of freeing up the key resources.
738 res = i_mod_hash_insert_nosync(hash, key, val, (mod_hash_hndl_t)0);
747 * Remove an element from the hash table matching 'key', and destroy it.
750 mod_hash_destroy(mod_hash_t *hash, mod_hash_key_t key)
757 if ((rv = i_mod_hash_remove_nosync(hash, key, &val)) == 0) {
759 * mod_hash_remove() takes care of freeing up the key resources.
771 * Find a value in the hash table corresponding to the given key.
774 i_mod_hash_find_nosync(mod_hash_t *hash, mod_hash_key_t key,
780 hashidx = i_mod_hash(hash, key);
783 if (MH_KEYCMP(hash, e->mhe_key, key) == 0) {
794 mod_hash_find(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t *val)
799 res = i_mod_hash_find_nosync(hash, key, val);
806 mod_hash_find_cb(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t *val,
812 res = i_mod_hash_find_nosync(hash, key, val);
814 find_cb(key, *val);
822 mod_hash_find_cb_rval(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t *val,
828 res = i_mod_hash_find_nosync(hash, key, val);
830 *cb_rval = find_cb(key, *val);
859 * function with the key/value pair for each element. The hashtable