diff options
author | ubq323 <ubq323@ubq323.website> | 2024-06-20 16:00:34 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-06-20 16:00:34 +0100 |
commit | 60b3369ab24f9bd2a4a6d638ab1b3013ebc29814 (patch) | |
tree | 3ff8ec7e95ef314266673b1b3d7bedb880a4a5b0 /mem.h | |
parent | 9ee73a8459eb2bb58adc29da02de312b7e4e7dca (diff) |
pass State *S everywhere
contains changes from a million years ago that i don't remember much about
Diffstat (limited to 'mem.h')
-rw-r--r-- | mem.h | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -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 |