Lines Matching defs:hdl
238 dict_length(dict_hdl_t *hdl)
240 return (hdl->dh_length);
247 dict_free(dict_hdl_t **hdl)
249 if ((*hdl)->dh_length > 0) {
251 for (i = 0; i < (*hdl)->dh_size; i++) {
253 for (this = (*hdl)->dh_buckets[i]; this != NULL;
260 free((*hdl)->dh_buckets);
261 free((*hdl));
262 *hdl = NULL;
273 dict_hdl_t *hdl;
275 if ((hdl = calloc(1, sizeof (dict_hdl_t))) == NULL)
277 hdl->dh_size = DICT_SIZE;
278 if ((hdl->dh_buckets = calloc(hdl->dh_size, sizeof (dict_bucket_t *)))
280 free(hdl);
283 hdl->dh_cmp = cmp ? cmp : cmp_addr;
284 hdl->dh_hash = hash ? hash : hash_addr;
285 return (hdl);
293 dict_get(dict_hdl_t *hdl, const void *key)
298 i = (*hdl->dh_hash)(key)%hdl->dh_size;
299 for (bucket = hdl->dh_buckets[i]; bucket != NULL;
301 if ((*hdl->dh_cmp)(key, bucket->db_key) == 0)
311 dict_put(dict_hdl_t *hdl, const void *key, void *value)
317 i = (*hdl->dh_hash)(key)%hdl->dh_size;
318 for (bucket = hdl->dh_buckets[i]; bucket != NULL;
320 if ((*hdl->dh_cmp)(key, bucket->db_key) == 0)
327 bucket->db_next = hdl->dh_buckets[i];
328 hdl->dh_buckets[i] = bucket;
329 hdl->dh_length++;
331 hdl->dh_change++;
341 dict_remove(dict_hdl_t *hdl, const void *key)
346 hdl->dh_change++;
347 i = (*hdl->dh_hash)(key)%hdl->dh_size;
349 for (pbucket = &hdl->dh_buckets[i]; *pbucket != NULL;
351 if ((*hdl->dh_cmp)(key, (*pbucket)->db_key) == 0) {
357 hdl->dh_length--;
371 dict_map(dict_hdl_t *hdl, void (*apply)(const void *, void **, void *),
376 uint64_t change_stamp = hdl->dh_change;
378 for (i = 0; i < hdl->dh_size; i++) {
379 for (bucket = hdl->dh_buckets[i]; bucket != NULL;
382 if (hdl->dh_change != change_stamp)