use pic_alloc/pic_free in initializing struct pic_heap
This commit is contained in:
+4
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user