summaryrefslogtreecommitdiff
path: root/mem.h
diff options
context:
space:
mode:
Diffstat (limited to 'mem.h')
-rw-r--r--mem.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/mem.h b/mem.h
index 8c528b9..d13e02f 100644
--- a/mem.h
+++ b/mem.h
@@ -3,18 +3,20 @@
#include <stddef.h>
#include "val.h"
+#include "vm.h"
+#include "state.h"
-void *M(void *p, size_t old, size_t new);
+void *M(State *S, void *ptr, 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 NEW(S,ty) (ty*)M(S, NULL, 0, sizeof(ty))
+#define NEW_ARR(S,ty,n) (ty*)M(S, NULL, 0, (n)*sizeof(ty))
+#define RENEW_ARR(S,p,ty,old,new) (ty*)M(S, (p), (old)*sizeof(ty), (new)*sizeof(ty))
+#define NEW_OBJ(S,ty, oty) (ty*)alloc_obj(S, sizeof(ty), oty)
-#define FREE(p,t) M(p, sizeof(t), 0)
-#define FREE_ARR(p,t,old) M(p, (old)*sizeof(t), 0)
+#define FREE(S,p,ty) M(S, p, sizeof(ty), 0)
+#define FREE_ARR(S,p,ty,old) M(S, p, (old)*sizeof(ty), 0)
-Obj *alloc_obj(size_t sz, ObjTy oty);
+Obj *alloc_obj(State *S, size_t sz, ObjTy oty);
#endif