aboutsummaryrefslogtreecommitdiffstats
path: root/st.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-05 03:43:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-05 03:43:45 +0000
commite5ac15998d29d5a239827fadc95ec3ff6d8f455a (patch)
tree8e6c4cf76940ceadee3627fd455e6437d499a135 /st.c
parent697b53d8a96db8ad797baa5fca37d6cec5d7ca9d (diff)
downloadruby-e5ac15998d29d5a239827fadc95ec3ff6d8f455a.tar.gz
* st.c (unpack_entries): reallocate bins if packed array size
is not same as initial bins size. based on a patch by Sokolov Yura <funny.falcon AT gmail.com>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r--st.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/st.c b/st.c
index f40ad33c8c..9c4a19fdd2 100644
--- a/st.c
+++ b/st.c
@@ -478,7 +478,12 @@ unpack_entries(register st_table *table)
table->bins = (st_table_entry **)&packed_bins;
tmp_table.entries_packed = 0;
tmp_table.num_entries = 0;
+#if ST_DEFAULT_INIT_TABLE_SIZE == ST_DEFAULT_PACKED_TABLE_SIZE
MEMZERO(tmp_table.bins, st_table_entry*, tmp_table.num_bins);
+#else
+ tmp_table.bins = st_realloc_bins(tmp_table.bins, ST_DEFAULT_INIT_TABLE_SIZE, tmp_table.num_bins);
+ tmp_table.num_bins = ST_DEFAULT_INIT_TABLE_SIZE;
+#endif
for (i = 0; i < table->num_entries; i++) {
/* packed table should be numhash */
st_index_t key = PKEY(table, i), value = PVAL(table, i);