Lines Matching refs:handle

52 static size_t ht_default_hash(HT_HANDLE *handle, const char *key);
131 ht_destroy_table(HT_HANDLE *handle) in ht_destroy_table() argument
136 if (handle == 0) in ht_destroy_table()
140 (void) ht_clean_table(handle); in ht_destroy_table()
141 while ((item = ht_findfirst(handle, &iterator)) != 0) in ht_destroy_table()
142 (void) ht_remove_item(handle, item->hi_key); in ht_destroy_table()
144 free(handle); in ht_destroy_table()
155 ht_get_total_items(HT_HANDLE *handle) in ht_get_total_items() argument
157 if (handle == 0) in ht_get_total_items()
160 return (handle->ht_total_items); in ht_get_total_items()
175 ht_default_hash(HT_HANDLE *handle, const char *key) in ht_default_hash() argument
180 if ((handle->ht_flags & HTHF_FIXED_KEY) == 0) { in ht_default_hash()
186 int key_len = handle->ht_key_size; in ht_default_hash()
194 rval = (hash_ndx * HASH_MESH_VALUE) & handle->ht_table_mask; in ht_default_hash()
207 ht_set_cmpfn(HT_HANDLE *handle, HT_CMP cmpfn) in ht_set_cmpfn() argument
209 if (handle) in ht_set_cmpfn()
210 handle->ht_cmp = cmpfn; in ht_set_cmpfn()
228 ht_add_item(HT_HANDLE *handle, const char *key, const void *data) in ht_add_item() argument
234 if (handle == 0 || key == 0) in ht_add_item()
237 if (handle->ht_flags & HTHF_FIXED_KEY) { in ht_add_item()
238 key_len = handle->ht_key_size; in ht_add_item()
242 if (key_len > handle->ht_key_size) in ht_add_item()
259 h_index = handle->ht_hash(handle, key); in ht_add_item()
264 item->hi_next = handle->ht_table[h_index].he_head; in ht_add_item()
265 handle->ht_table[h_index].he_head = item; in ht_add_item()
267 handle->ht_table[h_index].he_count++; in ht_add_item()
268 handle->ht_total_items++; in ht_add_item()
269 handle->ht_sequence++; in ht_add_item()
285 ht_replace_item(HT_HANDLE *handle, const char *key, const void *data) in ht_replace_item() argument
287 (void) ht_remove_item(handle, key); in ht_replace_item()
289 return (ht_add_item(handle, key, data)); in ht_replace_item()
306 ht_remove_item(HT_HANDLE *handle, const char *key) in ht_remove_item() argument
313 if (handle == 0 || key == 0) in ht_remove_item()
316 if ((handle->ht_flags & HTHF_FIXED_KEY) == 0) in ht_remove_item()
319 key_len = handle->ht_key_size; in ht_remove_item()
321 h_index = handle->ht_hash(handle, key); in ht_remove_item()
323 cur = handle->ht_table[h_index].he_head; in ht_remove_item()
328 (handle->ht_cmp(cur->hi_key, key, key_len) == 0)) { in ht_remove_item()
331 handle->ht_table[h_index].he_head = in ht_remove_item()
336 if (handle->ht_callback) in ht_remove_item()
337 handle->ht_callback(cur); in ht_remove_item()
347 handle->ht_table[h_index].he_count--; in ht_remove_item()
348 handle->ht_total_items--; in ht_remove_item()
349 handle->ht_sequence++; in ht_remove_item()
370 ht_find_item(HT_HANDLE *handle, const char *key) in ht_find_item() argument
376 if (handle == 0 || key == 0) in ht_find_item()
379 if ((handle->ht_flags & HTHF_FIXED_KEY) == 0) in ht_find_item()
382 key_len = handle->ht_key_size; in ht_find_item()
384 h_index = handle->ht_hash(handle, key); in ht_find_item()
385 cur = handle->ht_table[h_index].he_head; in ht_find_item()
389 (handle->ht_cmp(cur->hi_key, key, key_len) == 0)) in ht_find_item()
411 ht_register_callback(HT_HANDLE *handle, HT_CALLBACK callback) in ht_register_callback() argument
415 if (handle == 0) in ht_register_callback()
418 old_callback = handle->ht_callback; in ht_register_callback()
419 handle->ht_callback = callback; in ht_register_callback()
438 ht_clean_table(HT_HANDLE *handle) in ht_clean_table() argument
443 if (handle == 0) in ht_clean_table()
446 for (i = 0; i < handle->ht_table_size; i++) { in ht_clean_table()
447 cur = handle->ht_table[i].he_head; in ht_clean_table()
456 handle->ht_table[i].he_head = in ht_clean_table()
461 if (handle->ht_callback) in ht_clean_table()
462 handle->ht_callback(cur); in ht_clean_table()
470 handle->ht_table[i].he_count--; in ht_clean_table()
471 handle->ht_sequence++; in ht_clean_table()
474 cur = handle->ht_table[i].he_head; in ht_clean_table()
497 ht_mark_delete(HT_HANDLE *handle, HT_ITEM *item) in ht_mark_delete() argument
499 if (handle && item) { in ht_mark_delete()
501 handle->ht_total_items--; in ht_mark_delete()
511 ht_clear_delete(HT_HANDLE *handle, HT_ITEM *item) in ht_clear_delete() argument
513 if (handle && item) { in ht_clear_delete()
515 handle->ht_total_items++; in ht_clear_delete()
546 ht_findfirst(HT_HANDLE *handle, HT_ITERATOR *iterator) in ht_findfirst() argument
551 if (handle == 0 || iterator == 0 || handle->ht_total_items == 0) in ht_findfirst()
555 iterator->hti_handle = handle; in ht_findfirst()
556 iterator->hti_sequence = handle->ht_sequence; in ht_findfirst()
558 for (h_index = 0; h_index < handle->ht_table_size; ++h_index) { in ht_findfirst()
559 item = ht_bucket_search(handle->ht_table[h_index].he_head); in ht_findfirst()
588 HT_HANDLE *handle; in ht_findnext() local
599 handle = iterator->hti_handle; in ht_findnext()
602 iterator->hti_sequence != handle->ht_sequence) { in ht_findnext()
623 total = handle->ht_table_size; in ht_findnext()
625 item = ht_bucket_search(handle->ht_table[index].he_head); in ht_findnext()