Lines Matching refs:htab
47 lookup (NAME *htab, HASHTYPE hval, TYPE val __attribute__ ((unused))) in lookup() argument
51 size_t idx = 1 + (hval < htab->size ? hval : hval % htab->size); in lookup()
53 if (htab->table[idx].hashval != 0) in lookup()
57 if (htab->table[idx].hashval == hval in lookup()
58 && COMPARE (htab->table[idx].data, val) == 0) in lookup()
62 hash = 1 + hval % (htab->size - 2); in lookup()
67 idx = htab->size + idx - hash; in lookup()
72 if (htab->table[idx].hashval == hval in lookup()
73 && COMPARE (htab->table[idx].data, val) == 0) in lookup()
76 while (htab->table[idx].hashval); in lookup()
83 insert_entry_2 (NAME *htab, HASHTYPE hval, size_t idx, TYPE data) in insert_entry_2() argument
86 if (htab->table[idx].hashval == 0) in insert_entry_2()
89 htab->table[idx].next = htab->first; in insert_entry_2()
90 htab->first = &htab->table[idx]; in insert_entry_2()
93 if (htab->first == NULL) in insert_entry_2()
94 htab->first = htab->table[idx].next = &htab->table[idx]; in insert_entry_2()
97 htab->table[idx].next = htab->first->next; in insert_entry_2()
98 htab->first = htab->first->next = &htab->table[idx]; in insert_entry_2()
104 htab->table[idx].hashval = hval; in insert_entry_2()
105 htab->table[idx].data = data; in insert_entry_2()
107 ++htab->filled; in insert_entry_2()
108 if (100 * htab->filled > 90 * htab->size) in insert_entry_2()
112 __typeof__ (htab->first) first; in insert_entry_2()
114 __typeof__ (htab->first) runp; in insert_entry_2()
117 size_t old_size = htab->size; in insert_entry_2()
120 name##_ent *table = htab->table in insert_entry_2()
124 htab->size = next_prime (htab->size * 2); in insert_entry_2()
125 htab->filled = 0; in insert_entry_2()
127 first = htab->first; in insert_entry_2()
128 htab->first = NULL; in insert_entry_2()
130 htab->table = calloc ((1 + htab->size), sizeof (htab->table[0])); in insert_entry_2()
131 if (htab->table == NULL) in insert_entry_2()
135 htab->table = table; in insert_entry_2()
145 insert_entry_2 (htab, first->hashval, in insert_entry_2()
146 lookup (htab, first->hashval, first->data), in insert_entry_2()
155 insert_entry_2 (htab, runp->hashval, in insert_entry_2()
156 lookup (htab, runp->hashval, runp->data), runp->data); in insert_entry_2()
162 insert_entry_2 (htab, table[idx].hashval, in insert_entry_2()
163 lookup (htab, table[idx].hashval, table[idx].data), in insert_entry_2()
176 INIT(NAME) (NAME *htab, size_t init_size) in INIT()
182 htab->size = init_size; in INIT()
183 htab->filled = 0; in INIT()
185 htab->first = NULL; in INIT()
187 htab->table = (void *) calloc ((init_size + 1), sizeof (htab->table[0])); in INIT()
188 if (htab->table == NULL) in INIT()
199 FREE(NAME) (NAME *htab) in FREE()
201 free (htab->table); in FREE()
210 INSERT(NAME) (NAME *htab, HASHTYPE hval, TYPE data) in INSERT()
217 idx = lookup (htab, hval, data); in INSERT()
219 if (htab->table[idx].hashval != 0) in INSERT()
224 insert_entry_2 (htab, hval, idx, data); in INSERT()
234 INSERT(NAME) (NAME *htab, HASHTYPE hval, TYPE data) in INSERT()
241 idx = lookup (htab, hval, data); in INSERT()
244 insert_entry_2 (htab, hval, idx, data); in INSERT()
254 FIND(NAME) (NAME *htab, HASHTYPE hval, TYPE val) in FIND()
261 idx = lookup (htab, hval, val); in FIND()
263 if (htab->table[idx].hashval == 0) in FIND()
266 return htab->table[idx].data; in FIND()
275 ITERATEFCT(NAME) (NAME *htab, void **ptr) in ITERATEFCT()
284 p = htab->first; in ITERATEFCT()
296 if (htab->first == NULL) in ITERATEFCT()
298 p = htab->first->next; in ITERATEFCT()
302 if (p == htab->first) in ITERATEFCT()