found some small leaks with Purify

This commit is contained in:
ceriel 1993-01-18 15:10:01 +00:00
parent ba62ce0edc
commit 439ec389a0
5 changed files with 21 additions and 11 deletions

View file

@ -381,13 +381,6 @@ int2float(expp, tp)
int uns = exp->ex_type->tp_unsigned; int uns = exp->ex_type->tp_unsigned;
if (is_cp_cst(exp)) { if (is_cp_cst(exp)) {
*expp = new_expr();
**expp = *exp;
/* sprint(buf+1, "%ld", (long)(exp->VL_VALUE));
/* buf[0] = '-';
*/
exp = *expp; /* ??? */
exp->ex_type = tp; exp->ex_type = tp;
exp->ex_class = Float; exp->ex_class = Float;
flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH), uns); flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH), uns);

View file

@ -203,8 +203,9 @@ ch3bin(expp, oper, expr)
where o1 == (*expp)->VL_VALUE; where o1 == (*expp)->VL_VALUE;
and ((oper == AND) || (oper == OR)) and ((oper == AND) || (oper == OR))
*/ */
if ((oper == AND) == (ex->VL_VALUE != (arith)0)) if ((oper == AND) == (ex->VL_VALUE != (arith)0)) {
*expp = expr; *expp = expr;
}
else { else {
ex->ex_flags |= expr->ex_flags; ex->ex_flags |= expr->ex_flags;
free_expression(expr); free_expression(expr);
@ -260,8 +261,17 @@ ch3bin(expp, oper, expr)
#ifdef LINT #ifdef LINT
hwarning("condition in ?: expression is constant"); hwarning("condition in ?: expression is constant");
#endif /* LINT */ #endif /* LINT */
*expp = (*expp)->VL_VALUE ? if ((*expp)->VL_VALUE) {
expr->OP_LEFT : expr->OP_RIGHT; free_expression(*expp);
free_expression(expr->OP_RIGHT);
*expp = expr->OP_LEFT;
}
else {
free_expression(*expp);
free_expression(expr->OP_LEFT);
*expp = expr->OP_RIGHT;
}
free_expr(expr);
(*expp)->ex_flags |= EX_ILVALUE; (*expp)->ex_flags |= EX_ILVALUE;
} }
else { else {
@ -274,6 +284,7 @@ ch3bin(expp, oper, expr)
#ifdef LINT #ifdef LINT
hwarning("constant expression ignored"); hwarning("constant expression ignored");
#endif /* LINT */ #endif /* LINT */
free_expression(*expp);
*expp = expr; *expp = expr;
} }
else { else {

View file

@ -315,6 +315,7 @@ do_include()
if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){ if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){
lexerror("cannot open include file \"%s\"", filenm); lexerror("cannot open include file \"%s\"", filenm);
add_dependency(filenm); add_dependency(filenm);
free(filenm);
} }
else { else {
add_dependency(result); add_dependency(result);
@ -329,6 +330,7 @@ do_include()
C_ms_std(FileName, N_BINCL, 0); C_ms_std(FileName, N_BINCL, 0);
} }
#endif /* DBSYMTAB */ #endif /* DBSYMTAB */
if (result != filenm) free(filenm);
} }
} }
} }

View file

@ -63,6 +63,7 @@ AtEoIT()
return 0; return 0;
} }
extern char *source;
AtEoIF() AtEoIF()
{ {
@ -80,5 +81,7 @@ AtEoIF()
IncludeLevel--; IncludeLevel--;
#endif #endif
#endif /* NOPP */ #endif /* NOPP */
if (WorkingDir[0] != '\0') free(WorkingDir);
if (FileName != source) free(FileName);
return 0; return 0;
} }

View file

@ -155,7 +155,7 @@ next_option: /* to allow combined one-char options */
int i; int i;
register char *new = text; register char *new = text;
if (++inc_total > inc_max) { if (inc_total >= inc_max) {
inctable = (char **) inctable = (char **)
Realloc((char *)inctable, Realloc((char *)inctable,
(unsigned)((inc_max+=10)*sizeof(char *))); (unsigned)((inc_max+=10)*sizeof(char *)));
@ -167,6 +167,7 @@ next_option: /* to allow combined one-char options */
inctable[i] = new; inctable[i] = new;
new = tmp; new = tmp;
} }
inc_total++;
} }
else inctable[inc_pos] = 0; else inctable[inc_pos] = 0;
break; break;