diff --git a/include/picrin/irep.h b/include/picrin/irep.h index 67419c2f..36f16f88 100644 --- a/include/picrin/irep.h +++ b/include/picrin/irep.h @@ -59,6 +59,7 @@ struct pic_code { }; struct pic_irep { + PIC_OBJECT_HEADER struct pic_code *code; size_t clen, ccapa; int argc, localc; diff --git a/src/codegen.c b/src/codegen.c index 00b39a0c..91d02e1f 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -100,7 +100,7 @@ new_irep(pic_state *pic) { struct pic_irep *irep; - irep = (struct pic_irep *)pic_alloc(pic, sizeof(struct pic_irep)); + irep = (struct pic_irep *)pic_obj_alloc(pic, sizeof(struct pic_irep), PIC_TT_IREP); irep->code = (struct pic_code *)pic_alloc(pic, sizeof(struct pic_code) * 1024); irep->clen = 0; irep->ccapa = 1024; diff --git a/src/gc.c b/src/gc.c index 39181513..3d60d6f9 100644 --- a/src/gc.c +++ b/src/gc.c @@ -571,6 +571,9 @@ gc_finalize_object(pic_state *pic, struct pic_object *obj) break; } case PIC_TT_IREP: { + struct pic_irep *irep = (struct pic_irep *)obj; + pic_free(pic, irep->code); + pic_free(pic, irep->cv_tbl); break; } case PIC_TT_NIL: