Lines Matching refs:hash_tab
52 struct gh_t_hash_tab *hash_tab;
54 hash_tab =
56 if (hash_tab == NULL)
58 hash_tab->max_bucket = max_bucket;
59 hash_tab->val_size = val_size;
60 hash_tab->hash = hash;
61 hash_tab->match = match;
62 hash_tab->delete = delete == NULL ? noop : delete;
64 hash_tab->buckets = (struct element **)
66 if (hash_tab->buckets == NULL) {
67 gh_delete(hash_tab);
72 hash_tab->buckets[i] = NULL;
74 return hash_tab;
80 void gh_delete(struct gh_t_hash_tab *hash_tab)
85 if (hash_tab != NULL) {
86 if (hash_tab->buckets != NULL) {
87 for (i = 0; i < hash_tab->max_bucket; i++) {
88 for (elem = hash_tab->buckets[i]; elem != NULL;
91 (*hash_tab->delete) (elem->data);
94 hash_tab->val_size);
98 myfree(hash_tab->buckets, sizeof(struct element *)
99 * hash_tab->max_bucket);
102 myfree(hash_tab, sizeof(struct gh_t_hash_tab));
121 void *gh_find(struct gh_t_hash_tab *hash_tab, void *key)
125 elem = hash_tab->buckets[(*hash_tab->hash) (key, hash_tab->max_bucket)];
128 if ((*hash_tab->match) (key, elem->data))
149 void *gh_insert(struct gh_t_hash_tab *hash_tab, void *key, void *value)
156 hash_tab->val_size);
161 for (i = 0; i < hash_tab->val_size; i++)
164 i = (*hash_tab->hash) (key, hash_tab->max_bucket);
165 elem->next = hash_tab->buckets[i];
166 hash_tab->buckets[i] = elem;
195 * @hash_tab: Hash table
200 void gh_iterate(struct gh_t_hash_tab *hash_tab,
206 if (hash_tab && hash_tab->buckets)
207 for (i = 0; i < hash_tab->max_bucket; i++) {
208 elem = hash_tab->buckets[i];