ptr_dec with inlined freeing method

This commit is contained in:
dzaima 2021-11-20 17:09:05 +02:00
parent ff6e6aa9c7
commit cd97714ef5
2 changed files with 2 additions and 1 deletions

View File

@ -19,7 +19,7 @@ typedef struct ShArr {
static ShArr* shObjS(usz* x) { return RFLD(x, ShArr, a); }
static ShArr* shObj (B x) { return RFLD(a(x)->sh, ShArr, a); }
static ShArr* shObjP(Value* x) { return RFLD(((Arr*)x)->sh, ShArr, a); }
static void decSh(Value* x) { if (RARE(prnk(x)>1)) ptr_dec(shObjP(x));}
static void decSh(Value* x) { if (RARE(prnk(x)>1)) tptr_dec(shObjP(x), mm_free); }
// some array stuff

View File

@ -498,6 +498,7 @@ static void dec(B x) {
}
static void ptr_dec(void* x) { if(!--VALIDATEP((Value*)x)->refc) value_free(x); }
static void ptr_decR(void* x) { if(!--VALIDATEP((Value*)x)->refc) value_freeR(x); }
#define tptr_dec(X, F) ({ Value* x_ = (Value*)(X); if (!--VALIDATEP(x_)->refc) F(x_); })
static void decR(B x) {
if (!isVal(VALIDATE(x))) return;
Value* vx = v(x);