From 5e3f2dacf4d224205791ba0878699e1e2f751110 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 27 Nov 2013 13:04:03 +0900 Subject: [PATCH] Revert "add_heap_page should not be invoked in gc_alloc, but should be in obj_alloc" This reverts commit f11623f07554a470e5f9855459c9aefa3f48b48a. --- src/gc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gc.c b/src/gc.c index 1c9fddef..39c61b0b 100644 --- a/src/gc.c +++ b/src/gc.c @@ -139,7 +139,8 @@ gc_alloc(pic_state *pic, size_t size) if (p->s.size >= nunits) break; if (p == freep) { - return NULL; + if ((p = add_heap_page(pic)) == NULL) + return NULL; } } if (p->s.size == nunits) { @@ -493,11 +494,8 @@ pic_obj_alloc_unsafe(pic_state *pic, size_t size, enum pic_tt tt) if (obj == NULL) { pic_gc_run(pic); obj = (struct pic_object *)gc_alloc(pic, size); - if (obj == NULL) { - if (add_heap_page(pic) == NULL) - pic_abort(pic, "GC memory exhausted"); - obj = (struct pic_object *)gc_alloc(pic, size); - } + if (obj == NULL) + pic_abort(pic, "GC memory exhausted"); } obj->tt = tt;