From 012b387c89d2cb436946a18e81203026620e7c22 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 13 Oct 2013 16:56:30 +0900 Subject: [PATCH] change the semantics of pic_alloc/pic_free --- src/gc.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/gc.c b/src/gc.c index 8e7f0caf..1c5f4ded 100644 --- a/src/gc.c +++ b/src/gc.c @@ -23,6 +23,24 @@ init_heap_page(struct heap_page *heap) void * pic_alloc(pic_state *pic, size_t size) +{ + void *ptr; + + ptr = malloc(size); + if (ptr == NULL) { + pic_raise(pic, "memory exhausted"); + } + return ptr; +} + +void +pic_free(pic_state *pic, void *ptr) +{ + free(ptr); +} + +static void * +pic_gc_alloc(pic_state *pic, size_t size) { union header *freep, *p, *prevp; size_t nunits; @@ -51,8 +69,8 @@ pic_alloc(pic_state *pic, size_t size) return (void *)(p + 1); } -void -pic_free(pic_state *pic, void *ptr) +static void +pic_gc_free(pic_state *pic, void *ptr) { union header *bp, *p;