Home | History | Annotate | Download | only in config

Lines Matching defs:ht

98 ht_init(struct hashtab *ht, size_t sz)
102 ht->ht_tab = emalloc(sz * sizeof (ht->ht_tab[0]));
103 ht->ht_size = sz;
104 ht->ht_mask = sz - 1;
106 TAILQ_INIT(&ht->ht_tab[n]);
107 ht->ht_used = 0;
108 ht->ht_lim = HASHFRACTION(sz);
115 ht_expand(struct hashtab *ht)
121 n = ht->ht_size * 2;
125 oldh = ht->ht_tab;
127 for (i = 0; i < ht->ht_size; i++) {
134 free(ht->ht_tab);
135 ht->ht_tab = h;
136 ht->ht_mask = n;
137 ht->ht_size = ++n;
138 ht->ht_lim = HASHFRACTION(n);
209 struct hashtab *ht;
215 ht = &strings;
217 hpp = &ht->ht_tab[h & ht->ht_mask];
225 if (++ht->ht_used > ht->ht_lim)
226 ht_expand(ht);
233 struct hashtab *ht;
235 ht = ecalloc(1, sizeof *ht);
236 ht_init(ht, 8);
237 return (ht);
241 ht_free(struct hashtab *ht)
247 for (i = 0; i < ht->ht_size; i++) {
248 hpp = &ht->ht_tab[i];
252 ht->ht_used--;
256 assert(ht->ht_used == 0);
257 free(ht->ht_tab);
258 free(ht);
265 ht_insrep2(struct hashtab *ht, const char *nam1, const char *nam2, void *val, int replace)
272 hpp = &ht->ht_tab[h & ht->ht_mask];
284 if (++ht->ht_used > ht->ht_lim)
285 ht_expand(ht);
290 ht_insrep(struct hashtab *ht, const char *nam, void *val, int replace)
292 return ht_insrep2(ht, nam, NULL, val, replace);
299 ht_remove2(struct hashtab *ht, const char *name1, const char *name2)
306 hpp = &ht->ht_tab[h & ht->ht_mask];
314 ht->ht_used--;
321 ht_remove(struct hashtab *ht, const char *name)
323 return ht_remove2(ht, name, NULL);
327 ht_lookup2(struct hashtab *ht, const char *nam1, const char *nam2)
334 hpp = &ht->ht_tab[h & ht->ht_mask];
342 ht_lookup(struct hashtab *ht, const char *nam)
344 return ht_lookup2(ht, nam, NULL);
354 ht_enumerate2(struct hashtab *ht, ht_callback2 cbfunc2, void *arg)
361 for (i = 0; i < ht->ht_size; i++) {
362 hpp = &ht->ht_tab[i];
370 ht_enumerate(struct hashtab *ht, ht_callback cbfunc, void *arg)
377 for (i = 0; i < ht->ht_size; i++) {
378 hpp = &ht->ht_tab[i];
391 #define DEFHASH(HT, VT) \
392 struct HT { \
396 struct HT * \
397 HT##_create(void) \
399 struct HT *tbl; \
407 HT##_insert(struct HT *tbl, const char *name, struct VT *val) \
413 HT##_replace(struct HT *tbl, const char *name, struct VT *val) \
419 HT##_remove(struct HT *tbl, const char *name) \
425 HT##_lookup(struct HT *tbl, const char *name) \
430 struct HT##_enumcontext { \
436 HT##_enumerate_thunk(const char *name, void *value, void *voidctx) \
438 struct HT##_enumcontext *ctx = voidctx; \
444 HT##_enumerate(struct HT *tbl, \
448 struct HT##_enumcontext ctx; \
452 return ht_enumerate(&tbl->imp, HT##_enumerate_thunk, &ctx); \