replace use of malloc/free with pic_alloc/pic_free

This commit is contained in:
Yuichi Nishiwaki 2013-10-14 17:04:59 +09:00
parent a5db43ba91
commit 298a8e685f
3 changed files with 6 additions and 6 deletions

View File

@ -188,7 +188,7 @@ gc_finalize_object(pic_state *pic, struct pic_object *obj)
case PIC_TT_SYMBOL: {
char *name;
name = ((struct pic_symbol *)obj)->name;
free(name);
pic_free(pic, name);
break;
}
case PIC_TT_PAIR: {
@ -200,8 +200,8 @@ gc_finalize_object(pic_state *pic, struct pic_object *obj)
proc = (struct pic_proc *)obj;
/* free irep */
free(proc->u.irep->code);
free(proc->u.irep);
pic_free(pic, proc->u.irep->code);
pic_free(pic, proc->u.irep);
}
default:
pic_raise(pic, "logic flaw");

View File

@ -13,7 +13,7 @@ pic_intern_cstr(pic_state *pic, const char *name)
/* clone name string */
len = strlen(name);
sym->name = (char *)malloc(len + 1);
sym->name = (char *)pic_alloc(pic, len + 1);
strncpy(sym->name, name, len + 1);
return pic_obj_value(sym);

View File

@ -140,8 +140,8 @@ pic_codegen(pic_state *pic, pic_value obj, struct pic_env *env)
proc = (struct pic_proc *)pic_obj_alloc(pic, sizeof(struct pic_proc), PIC_TT_PROC);
proc->u.irep = irep = (struct pic_irep *)malloc(sizeof(struct pic_irep));
irep->code = code = (struct pic_code *)malloc(sizeof(struct pic_code) * 1024);
proc->u.irep = irep = (struct pic_irep *)pic_alloc(pic, sizeof(struct pic_irep));
irep->code = code = (struct pic_code *)pic_alloc(pic, sizeof(struct pic_code) * 1024);
irep->clen = 0;
irep->ccapa = 1024;