change the semantics of pic_alloc/pic_free
This commit is contained in:
parent
a0556087f9
commit
012b387c89
22
src/gc.c
22
src/gc.c
|
@ -23,6 +23,24 @@ init_heap_page(struct heap_page *heap)
|
||||||
|
|
||||||
void *
|
void *
|
||||||
pic_alloc(pic_state *pic, size_t size)
|
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;
|
union header *freep, *p, *prevp;
|
||||||
size_t nunits;
|
size_t nunits;
|
||||||
|
@ -51,8 +69,8 @@ pic_alloc(pic_state *pic, size_t size)
|
||||||
return (void *)(p + 1);
|
return (void *)(p + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
pic_free(pic_state *pic, void *ptr)
|
pic_gc_free(pic_state *pic, void *ptr)
|
||||||
{
|
{
|
||||||
union header *bp, *p;
|
union header *bp, *p;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue