From: ceriel Date: Tue, 20 Oct 1987 13:32:18 +0000 (+0000) Subject: fix in reference counts for sets X-Git-Tag: release-5-5~3795 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=688567a5321ce94a444531c1c24450d12175cb75;p=ack.git fix in reference counts for sets --- diff --git a/lang/m2/comp/chk_expr.c b/lang/m2/comp/chk_expr.c index 9a8c880c2..2ee76d19f 100644 --- a/lang/m2/comp/chk_expr.c +++ b/lang/m2/comp/chk_expr.c @@ -311,11 +311,6 @@ ChkExLinkOrName(expp) if (df->df_kind & (D_ENUM | D_CONST)) { /* Replace an enum-literal or a CONST identifier by its value. */ - if (df->df_type->tp_fund == T_SET) { - expp->nd_class = Set; - inc_refcount(expp->nd_set); - } - else expp->nd_class = Value; if (df->df_kind == D_ENUM) { expp->nd_INT = df->enm_val; expp->nd_symb = INTEGER; @@ -327,6 +322,11 @@ ChkExLinkOrName(expp) expp->nd_token = df->con_const; expp->nd_lineno = ln; } + if (df->df_type->tp_fund == T_SET) { + expp->nd_class = Set; + inc_refcount(expp->nd_set); + } + else expp->nd_class = Value; } if (!(df->df_kind & D_VALUE)) { @@ -426,7 +426,7 @@ MkSet(size) { register arith *s; - size = ((size + (int)word_size - 1) / (int)word_size + 1) * sizeof(arith); + size = (size / (int) word_size + 1) * sizeof(arith); s = (arith *) Malloc(size); clear((char *) s , size); s++; @@ -439,6 +439,7 @@ FreeSet(s) { dec_refcount(s); if (refcount(s) <= 0) { + assert(refcount(s) == 0); free((char *) (s-1)); } } diff --git a/lang/m2/comp/cstoper.c b/lang/m2/comp/cstoper.c index f75fdacb7..27b67ae42 100644 --- a/lang/m2/comp/cstoper.c +++ b/lang/m2/comp/cstoper.c @@ -251,7 +251,7 @@ cstset(expp) assert(expp->nd_symb == IN || expp->nd_left->nd_class == Set); set2 = expp->nd_right->nd_set; - setsize = (unsigned) expp->nd_right->nd_type->tp_size / (unsigned) word_size; + setsize = (unsigned) (expp->nd_right->nd_type->tp_size) / (unsigned) word_size; if (expp->nd_symb == IN) { unsigned i;