arena save/restore

This commit is contained in:
mattn
2014-06-04 10:20:51 +09:00
parent f18771eb42
commit 5410b9c46c
+4
View File
@@ -695,8 +695,10 @@ mrb_str_chars(mrb_state *mrb, mrb_value self)
return self;
}
while (p < e) {
int ai = mrb_gc_arena_save(mrb);
mrb_int len = utf8len((unsigned char*) p);
mrb_ary_push(mrb, result, mrb_str_new(mrb, p, len));
mrb_gc_arena_restore(mrb, ai);
p += len;
}
return result;
@@ -725,8 +727,10 @@ mrb_str_codepoints(mrb_state *mrb, mrb_value self)
return self;
}
while (p < e) {
int ai = mrb_gc_arena_save(mrb);
mrb_int len = utf8len((unsigned char*) p);
mrb_ary_push(mrb, result, mrb_fixnum_value(utf8code((unsigned char*) p)));
mrb_gc_arena_restore(mrb, ai);
p += len;
}
return result;