catch double-frees in debug mode
This commit is contained in:
parent
f87a1155f5
commit
28d434a201
5
src/h.h
5
src/h.h
@ -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--;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user