Lines Matching refs:hp

36 ctf_hash_create(ctf_hash_t *hp, ulong_t nelems)  in ctf_hash_create()  argument
46 bzero(hp, sizeof (ctf_hash_t)); in ctf_hash_create()
47 hp->h_buckets = (ushort_t *)_CTF_EMPTY; in ctf_hash_create()
48 hp->h_nbuckets = 1; in ctf_hash_create()
52 hp->h_nbuckets = 211; /* use a prime number of hash buckets */ in ctf_hash_create()
53 hp->h_nelems = nelems + 1; /* we use index zero as a sentinel */ in ctf_hash_create()
54 hp->h_free = 1; /* first free element is index 1 */ in ctf_hash_create()
56 hp->h_buckets = ctf_alloc(sizeof (ushort_t) * hp->h_nbuckets); in ctf_hash_create()
57 hp->h_chains = ctf_alloc(sizeof (ctf_helem_t) * hp->h_nelems); in ctf_hash_create()
59 if (hp->h_buckets == NULL || hp->h_chains == NULL) { in ctf_hash_create()
60 ctf_hash_destroy(hp); in ctf_hash_create()
64 bzero(hp->h_buckets, sizeof (ushort_t) * hp->h_nbuckets); in ctf_hash_create()
65 bzero(hp->h_chains, sizeof (ctf_helem_t) * hp->h_nelems); in ctf_hash_create()
71 ctf_hash_size(const ctf_hash_t *hp) in ctf_hash_size() argument
73 return (hp->h_nelems ? hp->h_nelems - 1 : 0); in ctf_hash_size()
96 ctf_hash_insert(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name) in ctf_hash_insert() argument
100 ctf_helem_t *hep = &hp->h_chains[hp->h_free]; in ctf_hash_insert()
106 if (hp->h_free >= hp->h_nelems) in ctf_hash_insert()
120 h = ctf_hash_compute(str, strlen(str)) % hp->h_nbuckets; in ctf_hash_insert()
121 hep->h_next = hp->h_buckets[h]; in ctf_hash_insert()
122 hp->h_buckets[h] = hp->h_free++; in ctf_hash_insert()
133 ctf_hash_define(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name) in ctf_hash_define() argument
136 ctf_helem_t *hep = ctf_hash_lookup(hp, fp, str, strlen(str)); in ctf_hash_define()
139 return (ctf_hash_insert(hp, fp, type, name)); in ctf_hash_define()
146 ctf_hash_lookup(ctf_hash_t *hp, ctf_file_t *fp, const char *key, size_t len) in ctf_hash_lookup() argument
153 ulong_t h = ctf_hash_compute(key, len) % hp->h_nbuckets; in ctf_hash_lookup()
155 for (i = hp->h_buckets[h]; i != 0; i = hep->h_next) { in ctf_hash_lookup()
156 hep = &hp->h_chains[i]; in ctf_hash_lookup()
168 ctf_hash_destroy(ctf_hash_t *hp) in ctf_hash_destroy() argument
170 if (hp->h_buckets != NULL && hp->h_nbuckets != 1) { in ctf_hash_destroy()
171 ctf_free(hp->h_buckets, sizeof (ushort_t) * hp->h_nbuckets); in ctf_hash_destroy()
172 hp->h_buckets = NULL; in ctf_hash_destroy()
175 if (hp->h_chains != NULL) { in ctf_hash_destroy()
176 ctf_free(hp->h_chains, sizeof (ctf_helem_t) * hp->h_nelems); in ctf_hash_destroy()
177 hp->h_chains = NULL; in ctf_hash_destroy()
182 ctf_hash_dump(const char *tag, ctf_hash_t *hp, ctf_file_t *fp) in ctf_hash_dump() argument
186 for (ushort_t h = 0; h < hp->h_nbuckets; h++) { in ctf_hash_dump()
189 for (ushort_t i = hp->h_buckets[h]; i != 0; i = hep->h_next) { in ctf_hash_dump()
193 hep = &hp->h_chains[i]; in ctf_hash_dump()