Lines Matching refs:htab
68 lookup (htab, hval, val)
69 NAME *htab;
74 size_t idx = 1 + hval % htab->size;
76 if (htab->table[idx].hashval != 0)
80 if (htab->table[idx].hashval == hval
81 && COMPARE (htab->table[idx].data, val) == 0)
85 hash = 1 + hval % (htab->size - 2);
90 idx = htab->size + idx - hash;
95 if (htab->table[idx].hashval == hval
96 && COMPARE (htab->table[idx].data, val) == 0)
99 while (htab->table[idx].hashval);
106 insert_entry_2 (NAME *htab, unsigned long int hval, size_t idx, TYPE data)
109 if (htab->table[idx].hashval == 0)
112 htab->table[idx].next = htab->first;
113 htab->first = &htab->table[idx];
116 if (htab->first == NULL)
117 htab->first = htab->table[idx].next = &htab->table[idx];
120 htab->table[idx].next = htab->first->next;
121 htab->first = htab->first->next = &htab->table[idx];
127 htab->table[idx].hashval = hval;
128 htab->table[idx].data = data;
130 ++htab->filled;
131 if (100 * htab->filled > 90 * htab->size)
135 __typeof__ (htab->first) first;
137 __typeof__ (htab->first) runp;
140 unsigned long int old_size = htab->size;
143 name##_ent *table = htab->table
147 htab->size = next_prime (htab->size * 2);
148 htab->filled = 0;
150 first = htab->first;
151 htab->first = NULL;
153 htab->table = calloc ((1 + htab->size), sizeof (htab->table[0]));
154 if (htab->table == NULL)
158 htab->table = table;
168 insert_entry_2 (htab, first->hashval,
169 lookup (htab, first->hashval, first->data),
178 insert_entry_2 (htab, runp->hashval,
179 lookup (htab, runp->hashval, runp->data), runp->data);
185 insert_entry_2 (htab, table[idx].hashval,
186 lookup (htab, table[idx].hashval, table[idx].data),
199 INIT(NAME) (htab, init_size)
200 NAME *htab;
207 htab->size = init_size;
208 htab->filled = 0;
210 htab->first = NULL;
212 htab->table = (void *) calloc ((init_size + 1), sizeof (htab->table[0]));
213 if (htab->table == NULL)
224 FREE(NAME) (htab)
225 NAME *htab;
227 free (htab->table);
236 INSERT(NAME) (htab, hval, data)
237 NAME *htab;
246 idx = lookup (htab, hval, data);
248 if (htab->table[idx].hashval != 0)
253 insert_entry_2 (htab, hval, idx, data);
263 INSERT(NAME) (htab, hval, data)
264 NAME *htab;
273 idx = lookup (htab, hval, data);
276 insert_entry_2 (htab, hval, idx, data);
286 FIND(NAME) (htab, hval, val)
287 NAME *htab;
296 idx = lookup (htab, hval, val);
298 if (htab->table[idx].hashval == 0)
301 return htab->table[idx].data;
310 ITERATEFCT(NAME) (htab, ptr)
311 NAME *htab;
321 p = htab->first;
333 if (htab->first == NULL)
335 p = htab->first->next;
339 if (p == htab->first)