Lines Matching refs:hp

35 ctf_hash_create(ctf_hash_t *hp, ulong_t nelems)  in ctf_hash_create()  argument
45 bzero(hp, sizeof (ctf_hash_t)); in ctf_hash_create()
46 hp->h_buckets = (ushort_t *)_CTF_EMPTY; in ctf_hash_create()
47 hp->h_nbuckets = 1; in ctf_hash_create()
51 hp->h_nbuckets = 211; /* use a prime number of hash buckets */ in ctf_hash_create()
52 hp->h_nelems = nelems + 1; /* we use index zero as a sentinel */ in ctf_hash_create()
53 hp->h_free = 1; /* first free element is index 1 */ in ctf_hash_create()
55 hp->h_buckets = ctf_alloc(sizeof (ushort_t) * hp->h_nbuckets); in ctf_hash_create()
56 hp->h_chains = ctf_alloc(sizeof (ctf_helem_t) * hp->h_nelems); in ctf_hash_create()
58 if (hp->h_buckets == NULL || hp->h_chains == NULL) { in ctf_hash_create()
59 ctf_hash_destroy(hp); in ctf_hash_create()
63 bzero(hp->h_buckets, sizeof (ushort_t) * hp->h_nbuckets); in ctf_hash_create()
64 bzero(hp->h_chains, sizeof (ctf_helem_t) * hp->h_nelems); in ctf_hash_create()
70 ctf_hash_size(const ctf_hash_t *hp) in ctf_hash_size() argument
72 return (hp->h_nelems ? hp->h_nelems - 1 : 0); in ctf_hash_size()
95 ctf_hash_insert(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name) in ctf_hash_insert() argument
99 ctf_helem_t *hep = &hp->h_chains[hp->h_free]; in ctf_hash_insert()
105 if (hp->h_free >= hp->h_nelems) in ctf_hash_insert()
119 h = ctf_hash_compute(str, strlen(str)) % hp->h_nbuckets; in ctf_hash_insert()
120 hep->h_next = hp->h_buckets[h]; in ctf_hash_insert()
121 hp->h_buckets[h] = hp->h_free++; in ctf_hash_insert()
132 ctf_hash_define(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name) in ctf_hash_define() argument
135 ctf_helem_t *hep = ctf_hash_lookup(hp, fp, str, strlen(str)); in ctf_hash_define()
138 return (ctf_hash_insert(hp, fp, type, name)); in ctf_hash_define()
145 ctf_hash_lookup(ctf_hash_t *hp, ctf_file_t *fp, const char *key, size_t len) in ctf_hash_lookup() argument
152 ulong_t h = ctf_hash_compute(key, len) % hp->h_nbuckets; in ctf_hash_lookup()
154 for (i = hp->h_buckets[h]; i != 0; i = hep->h_next) { in ctf_hash_lookup()
155 hep = &hp->h_chains[i]; in ctf_hash_lookup()
167 ctf_hash_destroy(ctf_hash_t *hp) in ctf_hash_destroy() argument
169 if (hp->h_buckets != NULL && hp->h_nbuckets != 1) { in ctf_hash_destroy()
170 ctf_free(hp->h_buckets, sizeof (ushort_t) * hp->h_nbuckets); in ctf_hash_destroy()
171 hp->h_buckets = NULL; in ctf_hash_destroy()
174 if (hp->h_chains != NULL) { in ctf_hash_destroy()
175 ctf_free(hp->h_chains, sizeof (ctf_helem_t) * hp->h_nelems); in ctf_hash_destroy()
176 hp->h_chains = NULL; in ctf_hash_destroy()