summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-30 12:49:10 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-30 12:49:10 +0000
commitcaa2bb47b35969918e67d3339441750255edb18c (patch)
treef9b5a80bd4671354318a83e6014cbddcfeb72d9b /st.c
parent8c9edc0082d8da99010872c3f103c7b5804fd856 (diff)
merges r25377 from trunk into ruby_1_9_1.
-- * st.c (unpack_entries): save table->bins and never change the table during unpacking. Because st_insert() may cause GC and refer the table, i.e. st_foreach(). [Bug #2196] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r--st.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/st.c b/st.c
index c6821467b3..541531d717 100644
--- a/st.c
+++ b/st.c
@@ -367,15 +367,17 @@ unpack_entries(register st_table *table)
{
int i;
struct st_table_entry *packed_bins[MAX_PACKED_NUMHASH*2];
- int num_entries = table->num_entries;
+ st_table tmp_table = *table;
- memcpy(packed_bins, table->bins, sizeof(struct st_table_entry *) * num_entries*2);
- table->entries_packed = 0;
- table->num_entries = 0;
- memset(table->bins, 0, sizeof(struct st_table_entry *) * table->num_bins);
- for (i = 0; i < num_entries; i++) {
- st_insert(table, (st_data_t)packed_bins[i*2], (st_data_t)packed_bins[i*2+1]);
+ memcpy(packed_bins, table->bins, sizeof(struct st_table_entry *) * table->num_entries*2);
+ table->bins = packed_bins;
+ tmp_table.entries_packed = 0;
+ tmp_table.num_entries = 0;
+ memset(tmp_table.bins, 0, sizeof(struct st_table_entry *) * tmp_table.num_bins);
+ for (i = 0; i < table->num_entries; i++) {
+ st_insert(&tmp_table, (st_data_t)packed_bins[i*2], (st_data_t)packed_bins[i*2+1]);
}
+ *table = tmp_table;
}
int