Commit 5410b9c4 authored by mattn's avatar mattn

arena save/restore

parent f18771eb
...@@ -695,8 +695,10 @@ mrb_str_chars(mrb_state *mrb, mrb_value self) ...@@ -695,8 +695,10 @@ mrb_str_chars(mrb_state *mrb, mrb_value self)
return self; return self;
} }
while (p < e) { while (p < e) {
int ai = mrb_gc_arena_save(mrb);
mrb_int len = utf8len((unsigned char*) p); mrb_int len = utf8len((unsigned char*) p);
mrb_ary_push(mrb, result, mrb_str_new(mrb, p, len)); mrb_ary_push(mrb, result, mrb_str_new(mrb, p, len));
mrb_gc_arena_restore(mrb, ai);
p += len; p += len;
} }
return result; return result;
...@@ -725,8 +727,10 @@ mrb_str_codepoints(mrb_state *mrb, mrb_value self) ...@@ -725,8 +727,10 @@ mrb_str_codepoints(mrb_state *mrb, mrb_value self)
return self; return self;
} }
while (p < e) { while (p < e) {
int ai = mrb_gc_arena_save(mrb);
mrb_int len = utf8len((unsigned char*) p); mrb_int len = utf8len((unsigned char*) p);
mrb_ary_push(mrb, result, mrb_fixnum_value(utf8code((unsigned char*) p))); mrb_ary_push(mrb, result, mrb_fixnum_value(utf8code((unsigned char*) p)));
mrb_gc_arena_restore(mrb, ai);
p += len; p += len;
} }
return result; return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment