Lines Matching defs:ht

14 #include <isc/ht.h>
25 #define ISC_HT_VALID(ht) ISC_MAGIC_VALID(ht, ISC_HT_MAGIC)
44 isc_ht_t *ht;
51 isc_ht_t *ht = NULL;
58 ht = isc_mem_get(mctx, sizeof(struct isc_ht));
59 if (ht == NULL) {
63 ht->mctx = NULL;
64 isc_mem_attach(mctx, &ht->mctx);
66 ht->size = ((size_t)1<<bits);
67 ht->mask = ((size_t)1<<bits)-1;
68 ht->count = 0;
70 ht->table = isc_mem_get(ht->mctx, ht->size * sizeof(isc_ht_node_t*));
71 if (ht->table == NULL) {
72 isc_mem_putanddetach(&ht->mctx, ht, sizeof(struct isc_ht));
76 for (i = 0; i < ht->size; i++) {
77 ht->table[i] = NULL;
80 ht->magic = ISC_HT_MAGIC;
82 *htp = ht;
88 isc_ht_t *ht;
93 ht = *htp;
94 REQUIRE(ISC_HT_VALID(ht));
96 ht->magic = 0;
98 for (i = 0; i < ht->size; i++) {
99 isc_ht_node_t *node = ht->table[i];
102 ht->count--;
103 isc_mem_put(ht->mctx, node,
110 INSIST(ht->count == 0);
112 isc_mem_put(ht->mctx, ht->table, ht->size * sizeof(isc_ht_node_t*));
113 isc_mem_putanddetach(&ht->mctx, ht, sizeof(struct isc_ht));
119 isc_ht_add(isc_ht_t *ht, const unsigned char *key,
125 REQUIRE(ISC_HT_VALID(ht));
129 node = ht->table[hash & ht->mask];
138 node = isc_mem_get(ht->mctx, offsetof(isc_ht_node_t, key) + keysize);
144 node->next = ht->table[hash & ht->mask];
147 ht->count++;
148 ht->table[hash & ht->mask] = node;
153 isc_ht_find(const isc_ht_t *ht, const unsigned char *key,
159 REQUIRE(ISC_HT_VALID(ht));
164 node = ht->table[hash & ht->mask];
178 isc_ht_delete(isc_ht_t *ht, const unsigned char *key, isc_uint32_t keysize) {
182 REQUIRE(ISC_HT_VALID(ht));
187 node = ht->table[hash & ht->mask];
192 ht->table[hash & ht->mask] = node->next;
195 isc_mem_put(ht->mctx, node,
198 ht->count--;
210 isc_ht_iter_create(isc_ht_t *ht, isc_ht_iter_t **itp) {
213 REQUIRE(ISC_HT_VALID(ht));
216 it = isc_mem_get(ht->mctx, sizeof(isc_ht_iter_t));
220 it->ht = ht;
232 isc_ht_t *ht;
237 ht = it->ht;
238 isc_mem_put(ht->mctx, it, sizeof(isc_ht_iter_t));
248 while (it->i < it->ht->size && it->ht->table[it->i] == NULL)
251 if (it->i == it->ht->size)
254 it->cur = it->ht->table[it->i];
268 } while (it->i < it->ht->size && it->ht->table[it->i] == NULL);
269 if (it->i >= it->ht->size)
271 it->cur = it->ht->table[it->i];
284 isc_ht_t *ht;
288 ht = it->ht;
294 } while (it->i < ht->size && ht->table[it->i] == NULL);
295 if (it->i >= ht->size)
298 it->cur = ht->table[it->i];
303 node = ht->table[hash & ht->mask];
311 ht->table[hash & ht->mask] = node->next;
314 isc_mem_put(ht->mctx, node,
316 ht->count--;
338 isc_ht_count(isc_ht_t *ht) {
339 REQUIRE(ISC_HT_VALID(ht));
341 return(ht->count);