From af80ba6b365b585887165f2c36cd266480331216 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 24 Mar 2014 15:14:54 +0900 Subject: [PATCH] pic_gc_protect now returns a value --- include/picrin.h | 2 +- src/gc.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/picrin.h b/include/picrin.h index 6c18fe27..0d250f7b 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -121,7 +121,7 @@ struct pic_object *pic_obj_alloc_unsafe(pic_state *, size_t, enum pic_tt); void pic_free(pic_state *, void *); void pic_gc_run(pic_state *); -void pic_gc_protect(pic_state *, pic_value); +pic_value pic_gc_protect(pic_state *, pic_value); int pic_gc_arena_preserve(pic_state *); void pic_gc_arena_restore(pic_state *, int); diff --git a/src/gc.c b/src/gc.c index 97b45195..2d42ade6 100644 --- a/src/gc.c +++ b/src/gc.c @@ -183,17 +183,19 @@ gc_protect(pic_state *pic, struct pic_object *obj) pic->arena[pic->arena_idx++] = obj; } -void +pic_value pic_gc_protect(pic_state *pic, pic_value v) { struct pic_object *obj; if (pic_vtype(v) != PIC_VTYPE_HEAP) { - return; + return v; } obj = pic_obj_ptr(v); gc_protect(pic, obj); + + return v; } int