catch double-frees in debug mode

This commit is contained in:
dzaima 2022-11-06 02:11:12 +02:00
parent f87a1155f5
commit 28d434a201

View File

@ -578,12 +578,15 @@ static inline B inc(B x) {
}
static inline void decG(B x) {
#if DEBUG
assert(isVal(x));
assert(isVal(x) && v(x)->refc>0);
#endif
Value* vx = v(x);
if(!--vx->refc) value_free(vx);
}
FORCE_INLINE void ptr_decT(Arr* x) { // assumes argument is an array and consists of non-heap-allocated elements
#if DEBUG
assert(x->refc>0);
#endif
if (x->refc==1) TIv(x,freeT)((Value*) x);
else x->refc--;
}