fix rtWrap_unwrap refcounting

This commit is contained in:
dzaima 2022-12-29 22:59:31 +02:00
parent 0589d63cc5
commit 168db4cf01

View File

@ -258,11 +258,11 @@ B rtWrap_wrap(B t, bool nnbi) {
#endif
return t;
}
B rtWrap_unwrap(B x) {
B rtWrap_unwrap(B x) { // consumes x
if (!isVal(x)) return x;
if (TY(x)==t_funWrap) { B r = c(WFun,x)->v; dec(x); return r; }
if (TY(x)==t_md1Wrap) { B r = c(WMd1,x)->v; dec(x); return r; }
if (TY(x)==t_md2Wrap) { B r = c(WMd2,x)->v; dec(x); return r; }
if (TY(x)==t_funWrap) { B r = c(WFun,x)->v; decG(x); return inc(r); }
if (TY(x)==t_md1Wrap) { B r = c(WMd1,x)->v; decG(x); return inc(r); }
if (TY(x)==t_md2Wrap) { B r = c(WMd2,x)->v; decG(x); return inc(r); }
return x;
}