From 42cc5042f31440a81530cee9d08fa480f1366b46 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 22 Jan 2015 17:08:41 +0900 Subject: [PATCH] use pic_alloc/pic_free in initializing struct pic_heap --- extlib/benz/gc.c | 8 ++++---- extlib/benz/include/picrin/gc.h | 4 ++-- extlib/benz/state.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extlib/benz/gc.c b/extlib/benz/gc.c index 39c94351..2fc69b74 100644 --- a/extlib/benz/gc.c +++ b/extlib/benz/gc.c @@ -57,24 +57,24 @@ heap_init(struct pic_heap *heap) } struct pic_heap * -pic_heap_open() +pic_heap_open(pic_state *pic) { struct pic_heap *heap; - heap = (struct pic_heap *)calloc(1, sizeof(struct pic_heap)); + heap = pic_calloc(pic, 1, sizeof(struct pic_heap)); heap_init(heap); return heap; } void -pic_heap_close(struct pic_heap *heap) +pic_heap_close(pic_state *pic, struct pic_heap *heap) { struct heap_page *page; while (heap->pages) { page = heap->pages; heap->pages = heap->pages->next; - free(page); + pic_free(pic, page); } } diff --git a/extlib/benz/include/picrin/gc.h b/extlib/benz/include/picrin/gc.h index 9f165d80..c7ed0426 100644 --- a/extlib/benz/include/picrin/gc.h +++ b/extlib/benz/include/picrin/gc.h @@ -14,8 +14,8 @@ extern "C" { struct pic_heap; -struct pic_heap *pic_heap_open(); -void pic_heap_close(struct pic_heap *); +struct pic_heap *pic_heap_open(pic_state *); +void pic_heap_close(pic_state *, struct pic_heap *); #if defined(__cplusplus) } diff --git a/extlib/benz/state.c b/extlib/benz/state.c index 51f8189e..cc2042f6 100644 --- a/extlib/benz/state.c +++ b/extlib/benz/state.c @@ -49,7 +49,7 @@ pic_open(int argc, char *argv[], char **envp) pic->xpend = pic->xpbase + PIC_RESCUE_SIZE; /* memory heap */ - pic->heap = pic_heap_open(); + pic->heap = pic_heap_open(pic); /* symbol table */ xh_init_str(&pic->syms, sizeof(pic_sym *)); @@ -232,7 +232,7 @@ pic_close(pic_state *pic) pic_gc_run(pic); /* free heaps */ - pic_heap_close(pic->heap); + pic_heap_close(pic, pic->heap); /* free runtime context */ free(pic->stbase);