From 60b3369ab24f9bd2a4a6d638ab1b3013ebc29814 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 20 Jun 2024 16:00:34 +0100 Subject: pass State *S everywhere contains changes from a million years ago that i don't remember much about --- mem.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'mem.h') diff --git a/mem.h b/mem.h index 8c528b9..d13e02f 100644 --- a/mem.h +++ b/mem.h @@ -3,18 +3,20 @@ #include #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 -- cgit v1.2.3