#ifndef _mem_h #define _mem_h #include #include "val.h" void *M(void *p, size_t old, size_t new); #define NEW(t) (t*)M(NULL, 0, sizeof(t)) #define NEW_ARR(t,n) (t*)M(NULL, 0, (n)*sizeof(t)) #define RENEW_ARR(p,t,old,new) (t*)M((p), (old)*sizeof(t), (new)*sizeof(t)) #define NEW_OBJ(t, oty) (t*)alloc_obj(sizeof(t), oty) #define FREE(p,t) M(p, sizeof(t), 0) Obj *alloc_obj(size_t sz, ObjTy oty); #endif