add pic_realloc

This commit is contained in:
Yuichi Nishiwaki 2013-10-16 11:21:41 +09:00
parent 40a971230d
commit b60e4df3d9
2 changed files with 11 additions and 0 deletions

View File

@ -31,6 +31,7 @@ typedef struct {
typedef pic_value (*pic_func_t)(pic_state *);
void *pic_alloc(pic_state *, size_t);
void *pic_realloc(pic_state *, void *, size_t);
struct pic_object *pic_obj_alloc(pic_state *, size_t, enum pic_tt);
void pic_free(pic_state *, void *);

View File

@ -43,6 +43,16 @@ pic_alloc(pic_state *pic, size_t size)
return ptr;
}
void *
pic_realloc(pic_state *pic, void *ptr, size_t size)
{
ptr = realloc(ptr, size);
if (ptr == NULL) {
pic_raise(pic, "memory exhausted");
}
return ptr;
}
void
pic_free(pic_state *pic, void *ptr)
{