diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-09-12 12:42:39 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-09-12 12:42:39 +0900 |
| commit | 48c5321dca85025b8b11e43c8db2726fccb45b9d (patch) | |
| tree | 26f72cf0dfdfae040bc92b31c99f870c8c5fcf01 /src/hash.c | |
| parent | 7ea8803e06d349105c12e4470b34626b60447599 (diff) | |
| download | mruby-48c5321dca85025b8b11e43c8db2726fccb45b9d.tar.gz mruby-48c5321dca85025b8b11e43c8db2726fccb45b9d.zip | |
constify pointer from RARRAY_PTR to detect potential write barrier bugs.
if you see compiler errors due to this commit, you'd better to use array-modifying
functions, e.g. mrb_ary_set() or mrb_ary_push(), otherwise you might see nasty
GC bugs in the future. if you are sure what you are doing, replace `RARRAY_PTR(ary)`
by `mrb_ary_ptr(ary)->ptr`. but be warned.
Diffstat (limited to 'src/hash.c')
| -rw-r--r-- | src/hash.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/hash.c b/src/hash.c index aa0322c8c..0bda2b48b 100644 --- a/src/hash.c +++ b/src/hash.c @@ -698,12 +698,13 @@ mrb_hash_keys(mrb_state *mrb, mrb_value hash) { khash_t(ht) *h = RHASH_TBL(hash); khiter_t k; - mrb_value ary, *p; + mrb_value ary; + mrb_value *p; if (!h || kh_size(h) == 0) return mrb_ary_new(mrb); ary = mrb_ary_new_capa(mrb, kh_size(h)); mrb_ary_set(mrb, ary, kh_size(h)-1, mrb_nil_value()); - p = RARRAY_PTR(ary); + p = mrb_ary_ptr(ary)->ptr; for (k = kh_begin(h); k != kh_end(h); k++) { if (kh_exist(h, k)) { mrb_value kv = kh_key(h, k); |
