pic_gc_protect now returns a value

This commit is contained in:
Yuichi Nishiwaki 2014-03-24 15:14:54 +09:00
parent f2717910d0
commit af80ba6b36
2 changed files with 5 additions and 3 deletions

View File

@ -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);

View File

@ -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