diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-04-12 21:45:01 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-04-12 21:45:01 +0900 |
| commit | 17f4835141f456ae63a67dd52f96c475460ad781 (patch) | |
| tree | 4dc7edc6d2a624b7a2622ea6c025de136182d1c8 /mrbgems/mruby-struct/src/struct.c | |
| parent | 9e3fe6c53d6650fb7909a77b578fb6a55fbe2148 (diff) | |
| download | mruby-17f4835141f456ae63a67dd52f96c475460ad781.tar.gz mruby-17f4835141f456ae63a67dd52f96c475460ad781.zip | |
Restore arena index since large struct may create many Proc objects; a patch from @take-cheeze; ref #2052
Diffstat (limited to 'mrbgems/mruby-struct/src/struct.c')
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 19807073c..4f4c3533e 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -238,6 +238,7 @@ make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * k mrb_sym id; mrb_int i, len; struct RClass *c; + int ai; if (mrb_nil_p(name)) { c = mrb_class_new(mrb, klass); @@ -265,6 +266,7 @@ make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * k /* RSTRUCT(nstr)->basic.c->super = c->c; */ ptr_members = RARRAY_PTR(members); len = RARRAY_LEN(members); + ai = mrb_gc_arena_save(mrb); for (i=0; i< len; i++) { mrb_sym id = mrb_symbol(ptr_members[i]); if (mrb_is_local_id(id) || mrb_is_const_id(id)) { @@ -275,6 +277,7 @@ make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * k mrb_define_method_id(mrb, c, id, mrb_struct_ref, MRB_ARGS_NONE()); } mrb_define_method_id(mrb, c, mrb_id_attrset(mrb, id), mrb_struct_set_m, MRB_ARGS_REQ(1)); + mrb_gc_arena_restore(mrb, ai); } } return nstr; |
