Lines Matching refs:table
57 #define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0) argument
59 #define do_hash(key,table) (unsigned int)(*(table)->type->hash)((key)) argument
60 #define do_hash_bin(key,table) (do_hash(key, table)%(table)->num_bins) argument
200 st_free_table(table) in st_free_table() argument
201 st_table *table; in st_free_table()
206 for(i = 0; i < table->num_bins; i++) {
207 ptr = table->bins[i];
214 free(table->bins);
215 free(table);
218 #define PTR_NOT_EQUAL(table, ptr, hash_val, key) \ argument
219 ((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
227 #define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\ argument
228 bin_pos = hash_val%(table)->num_bins;\
229 ptr = (table)->bins[bin_pos];\
230 if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
232 while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
240 st_lookup(table, key, value) in st_lookup() argument
241 st_table *table; in st_lookup()
248 hash_val = do_hash(key, table);
249 FIND_ENTRY(table, ptr, hash_val, bin_pos);
260 #define ADD_DIRECT(table, key, value, hash_val, bin_pos)\ argument
263 if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\
264 rehash(table);\
265 bin_pos = hash_val % table->num_bins;\
273 entry->next = table->bins[bin_pos];\
274 table->bins[bin_pos] = entry;\
275 table->num_entries++;\
279 st_insert(table, key, value) in st_insert() argument
280 register st_table *table; in st_insert()
287 hash_val = do_hash(key, table);
288 FIND_ENTRY(table, ptr, hash_val, bin_pos);
291 ADD_DIRECT(table, key, value, hash_val, bin_pos);
301 st_add_direct(table, key, value) in st_add_direct() argument
302 st_table *table; in st_add_direct()
308 hash_val = do_hash(key, table);
309 bin_pos = hash_val % table->num_bins;
310 ADD_DIRECT(table, key, value, hash_val, bin_pos);
314 rehash(table) in rehash() argument
315 register st_table *table; in rehash()
318 int i, old_num_bins = table->num_bins, new_num_bins;
325 ptr = table->bins[i];
334 free(table->bins);
335 table->num_bins = new_num_bins;
336 table->bins = new_bins;
381 st_delete(table, key, value) in st_delete() argument
382 register st_table *table; in st_delete()
390 hash_val = do_hash_bin(*key, table);
391 ptr = table->bins[hash_val];
398 if (EQUAL(table, *key, ptr->key)) {
399 table->bins[hash_val] = ptr->next;
400 table->num_entries--;
408 if (EQUAL(table, ptr->next->key, *key)) {
411 table->num_entries--;
423 st_delete_safe(table, key, value, never) in st_delete_safe() argument
424 register st_table *table; in st_delete_safe()
432 hash_val = do_hash_bin(*key, table);
433 ptr = table->bins[hash_val];
441 if ((ptr->key != never) && EQUAL(table, ptr->key, *key)) {
442 table->num_entries--;
467 st_cleanup_safe(table, never) in st_cleanup_safe() argument
468 st_table *table; in st_cleanup_safe()
471 int num_entries = table->num_entries;
473 st_foreach(table, delete_never, never);
474 table->num_entries = num_entries;
478 st_foreach(table, func, arg) in st_foreach() argument
479 st_table *table; in st_foreach()
487 for(i = 0; i < table->num_bins; i++) {
489 for(ptr = table->bins[i]; ptr != 0;) {
494 if (i < table->num_bins) {
495 for (tmp = table->bins[i]; tmp; tmp=tmp->next) {
513 table->bins[i] = ptr->next;
520 table->num_entries--;