add our own malloc implementation (just a mock for now)

This commit is contained in:
Yuichi Nishiwaki 2013-10-10 16:44:51 +09:00
parent ebffe5a22e
commit 97ba95e12f
2 changed files with 31 additions and 0 deletions

View File

@ -6,6 +6,10 @@
typedef struct {
} pic_state;
void *pic_alloc(pic_state *, size_t);
struct pic_object *pic_gc_alloc(pic_state *, size_t, enum pic_tt);
void pic_free(pic_state *, void *);
pic_state *pic_open();
void pic_close(pic_state *);

27
src/gc.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdlib.h>
#include "picrin.h"
void *
pic_alloc(pic_state *pic, size_t size)
{
/* mock */
return malloc(size);
}
struct pic_object *
pic_gc_alloc(pic_state *pic, size_t size, enum pic_tt tt)
{
struct pic_object *obj;
obj = (struct pic_object *)malloc(size);
obj->tt = tt;
return obj;
}
void
pic_free(pic_state *pic, void *ptr)
{
free(ptr);
}