From bb3447173b52f6a24b2df1dba9fb93ddb48426bb Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 23 Dec 2014 22:28:33 +0900 Subject: khash.h: keep key/value table accessible from original hashtable during resize; fix #2682 --- include/mruby/khash.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/mruby/khash.h b/include/mruby/khash.h index 8a62e3ee6..6a4861bda 100644 --- a/include/mruby/khash.h +++ b/include/mruby/khash.h @@ -148,20 +148,23 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len) new_n_buckets = KHASH_MIN_SIZE; \ khash_power2(new_n_buckets); \ { \ + kh_##name##_t hh; \ uint8_t *old_ed_flags = h->ed_flags; \ khkey_t *old_keys = h->keys; \ khval_t *old_vals = h->vals; \ khint_t old_n_buckets = h->n_buckets; \ khint_t i; \ - h->n_buckets = new_n_buckets; \ - kh_alloc_##name(mrb, h); \ + hh.n_buckets = new_n_buckets; \ + kh_alloc_##name(mrb, &hh); \ /* relocate */ \ for (i=0 ; i