summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-05-29 22:14:32 +0900
committerYukihiro Matsumoto <[email protected]>2012-05-29 22:14:32 +0900
commit42b4060c9d75601b81b537323b969c69212a520e (patch)
treea1cc38e7b41cc8f036628f2d70c788e107d24640 /src
parent836fed4c330495944e60398bf0863d3fef285c5b (diff)
downloadmruby-42b4060c9d75601b81b537323b969c69212a520e.tar.gz
mruby-42b4060c9d75601b81b537323b969c69212a520e.zip
force room in arena before raising arena overflow error
Diffstat (limited to 'src')
-rw-r--r--src/gc.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/gc.c b/src/gc.c
index 46bce642d..0ba6e3e76 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -261,21 +261,10 @@ mrb_obj_alloc(mrb_state *mrb, enum mrb_vtype ttype, struct RClass *cls)
}
mrb->live++;
- if (mrb->arena_idx > MRB_ARENA_SIZE - 4) {
- struct RBasic **p, **q, **e;
-
- p = q = mrb->arena;
- e = p + mrb->arena_idx;
- while (p < e) {
- if (is_white(*p))
- *q++ = *p;
- p++;
- }
- if (p == q) {
- /* arena overflow error */
- mrb_raise(mrb, E_TYPE_ERROR, "arena overflow error");
- }
- mrb->arena_idx = q - mrb->arena;
+ if (mrb->arena_idx > MRB_ARENA_SIZE) {
+ /* arena overflow error */
+ mrb->arena_idx = MRB_ARENA_SIZE - 2; /* force room in arena */
+ mrb_raise(mrb, mrb->eRuntimeError_class, "arena overflow error");
}
mrb->arena[mrb->arena_idx++] = p;
memset(p, 0, sizeof(RVALUE));