Lines Matching refs:hp

35 	refhash_t *hp;  in refhash_create()  local
38 hp = kmem_alloc(sizeof (refhash_t), km_flags); in refhash_create()
39 if (hp == NULL) in refhash_create()
41 hp->rh_buckets = kmem_zalloc(bucket_count * sizeof (list_t), km_flags); in refhash_create()
42 if (hp->rh_buckets == NULL) { in refhash_create()
43 kmem_free(hp, sizeof (refhash_t)); in refhash_create()
46 hp->rh_bucket_count = bucket_count; in refhash_create()
49 list_create(&hp->rh_buckets[i], sizeof (refhash_link_t), in refhash_create()
52 list_create(&hp->rh_objs, sizeof (refhash_link_t), in refhash_create()
55 hp->rh_obj_size = obj_size; in refhash_create()
56 hp->rh_link_off = link_off; in refhash_create()
57 hp->rh_tag_off = tag_off; in refhash_create()
58 hp->rh_hash = hash; in refhash_create()
59 hp->rh_cmp = cmp; in refhash_create()
60 hp->rh_dtor = dtor; in refhash_create()
62 return (hp); in refhash_create()
66 refhash_destroy(refhash_t *hp) in refhash_destroy() argument
68 ASSERT(list_is_empty(&hp->rh_objs)); in refhash_destroy()
70 kmem_free(hp->rh_buckets, hp->rh_bucket_count * sizeof (list_t)); in refhash_destroy()
71 kmem_free(hp, sizeof (refhash_t)); in refhash_destroy()
75 refhash_insert(refhash_t *hp, void *op) in refhash_insert() argument
78 refhash_link_t *lp = obj_to_link(hp, op); in refhash_insert()
80 bucket = hp->rh_hash(obj_to_tag(hp, op)) % hp->rh_bucket_count; in refhash_insert()
85 list_insert_tail(&hp->rh_buckets[bucket], lp); in refhash_insert()
86 list_insert_tail(&hp->rh_objs, lp); in refhash_insert()
90 refhash_delete(refhash_t *hp, void *op) in refhash_delete() argument
92 refhash_link_t *lp = obj_to_link(hp, op); in refhash_delete()
95 bucket = hp->rh_hash(obj_to_tag(hp, op)) % hp->rh_bucket_count; in refhash_delete()
96 list_remove(&hp->rh_buckets[bucket], lp); in refhash_delete()
97 list_remove(&hp->rh_objs, lp); in refhash_delete()
98 hp->rh_dtor(op); in refhash_delete()
102 refhash_remove(refhash_t *hp, void *op) in refhash_remove() argument
104 refhash_link_t *lp = obj_to_link(hp, op); in refhash_remove()
109 refhash_delete(hp, op); in refhash_remove()
114 refhash_lookup(refhash_t *hp, const void *tp) in refhash_lookup() argument
120 bucket = hp->rh_hash(tp) % hp->rh_bucket_count; in refhash_lookup()
121 for (lp = list_head(&hp->rh_buckets[bucket]); lp != NULL; in refhash_lookup()
122 lp = list_next(&hp->rh_buckets[bucket], lp)) { in refhash_lookup()
123 op = link_to_obj(hp, lp); in refhash_lookup()
124 if (hp->rh_cmp(obj_to_tag(hp, op), tp) == 0 && in refhash_lookup()
134 refhash_linear_search(refhash_t *hp, refhash_eval_f eval, void *arg) in refhash_linear_search() argument
139 for (lp = list_head(&hp->rh_objs); lp != NULL; in refhash_linear_search()
140 lp = list_next(&hp->rh_objs, lp)) { in refhash_linear_search()
141 op = link_to_obj(hp, lp); in refhash_linear_search()
150 refhash_hold(refhash_t *hp, void *op) in refhash_hold() argument
152 refhash_link_t *lp = obj_to_link(hp, op); in refhash_hold()
158 refhash_rele(refhash_t *hp, void *op) in refhash_rele() argument
160 refhash_link_t *lp = obj_to_link(hp, op); in refhash_rele()
165 refhash_remove(hp, op); in refhash_rele()
169 refhash_first(refhash_t *hp) in refhash_first() argument
173 lp = list_head(&hp->rh_objs); in refhash_first()
179 return (link_to_obj(hp, lp)); in refhash_first()
183 refhash_next(refhash_t *hp, void *op) in refhash_next() argument
187 lp = obj_to_link(hp, op); in refhash_next()
188 while ((lp = list_next(&hp->rh_objs, lp)) != NULL) { in refhash_next()
193 refhash_rele(hp, op); in refhash_next()
199 return (link_to_obj(hp, lp)); in refhash_next()
203 refhash_obj_valid(refhash_t *hp, const void *op) in refhash_obj_valid() argument
205 const refhash_link_t *lp = obj_to_link(hp, op); in refhash_obj_valid()