From db75df2624a4a2745b37d288a9c68193f3793517 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 16 Jan 2014 22:02:30 +0900 Subject: [PATCH] add heap finializer --- include/picrin/gc.h | 1 + src/gc.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/picrin/gc.h b/include/picrin/gc.h index fc5a644d..4970196f 100644 --- a/include/picrin/gc.h +++ b/include/picrin/gc.h @@ -26,5 +26,6 @@ struct pic_heap { }; void init_heap(struct pic_heap *); +void finalize_heap(struct pic_heap *); #endif diff --git a/src/gc.c b/src/gc.c index 925ca161..027cba08 100644 --- a/src/gc.c +++ b/src/gc.c @@ -34,6 +34,18 @@ init_heap(struct pic_heap *heap) #endif } +void +finalize_heap(struct pic_heap *heap) +{ + struct heap_page *page; + + while (heap->pages) { + page = heap->pages; + heap->pages = heap->pages->next; + free(page); + } +} + static void gc_free(pic_state *, union header *); static void