summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
-rw-r--r--st.c38
1 files changed, 26 insertions, 12 deletions
@@ -718,7 +718,9 @@ count_collision(const struct st_hash_type *type)
#error "REBUILD_THRESHOLD should be >= 2"
#endif
-static void rebuild_table_with(st_table *new_tab, st_table *tab);
/* Rebuild table TAB. Rebuilding removes all deleted bins and entries
and can change size of the table entries and bins arrays.
@@ -744,11 +746,13 @@ rebuild_table(st_table *tab)
new_tab = st_init_table_with_size(tab->type,
2 * tab->num_entries - 1);
rebuild_table_with(new_tab, tab);
}
}
static void
-rebuild_table_with(st_table *new_tab, st_table *tab)
{
st_index_t i, ni;
unsigned int size_ind;
@@ -780,16 +784,24 @@ rebuild_table_with(st_table *new_tab, st_table *tab)
new_tab->num_entries++;
ni++;
}
- if (new_tab != tab) {
- tab->entry_power = new_tab->entry_power;
- tab->bin_power = new_tab->bin_power;
- tab->size_ind = new_tab->size_ind;
- free(tab->bins);
- tab->bins = new_tab->bins;
- free(tab->entries);
- tab->entries = new_tab->entries;
- free(new_tab);
- }
tab->entries_start = 0;
tab->entries_bound = tab->num_entries;
tab->rebuilds_num++;
@@ -2319,6 +2331,8 @@ rb_st_compact_table(st_table *tab)
/* Compaction: */
st_table *new_tab = st_init_table_with_size(tab->type, 2 * num);
rebuild_table_with(new_tab, tab);
}
}