From e94a7e240ff8d346868731247bf800b91a278a5c Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 26 May 2013 22:57:54 +0200 Subject: [PATCH] inpcom.c, simplify tfree() usage --- src/frontend/inpcom.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 6d70f865c..7773b245d 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -211,8 +211,7 @@ read_a_lib(char *y, int call_depth, char *dir_name) newfp = inp_pathopen(big_buff2, "r"); if (!newfp) { fprintf(cp_err, "Error: Could not find library file %s\n", y); - if (copyy) - tfree(copyy); /* allocated by the cp_tildexpand() above */ + tfree(copyy); /* allocated by the cp_tildexpand() above */ return FALSE; } @@ -234,8 +233,7 @@ read_a_lib(char *y, int call_depth, char *dir_name) fclose(newfp); } - if (copyy) - tfree(copyy); /* allocated by the cp_tildexpand() above */ + tfree(copyy); /* allocated by the cp_tildexpand() above */ return TRUE; } @@ -398,8 +396,7 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile s = skip_ws(s); /* advance past space chars */ /* only the last title line remains valid */ - if (new_title != NULL) - tfree(new_title); + tfree(new_title); new_title = copy(s); if ((s = strchr(new_title, '\n')) != NULL) *s = ' '; @@ -462,8 +459,7 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile newfp = inp_pathopen(big_buff2, "r"); if (!newfp) { perror(y); - if (copyy) - tfree(copyy); /* allocated by the cp_tildexpand() above */ + tfree(copyy); /* allocated by the cp_tildexpand() above */ fprintf(cp_err, "Error: .include statement failed.\n"); tfree(buffer); /* allocated by readline() above */ controlled_exit(EXIT_FAILURE); @@ -483,8 +479,7 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile (void) fclose(newfp); } - if (copyy) - tfree(copyy); /* allocated by the cp_tildexpand() above */ + tfree(copyy); /* allocated by the cp_tildexpand() above */ /* Make the .include a comment */ *buffer = '*'; @@ -636,7 +631,7 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile /* Replace first line with the new title, if available */ if (new_title != NULL) { - if (cc->li_line) tfree(cc->li_line); + tfree(cc->li_line); cc->li_line = new_title; } @@ -1631,8 +1626,7 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines) model_bin_match(used_model_names[i], model_name)) found_model = TRUE; } - if (model_type) - tfree(model_type); + tfree(model_type); if (!found_model) *line = '*'; tfree(model_name); @@ -1810,10 +1804,8 @@ inp_fix_ternary_operator_str(char *line, bool all) tfree(conditional); tfree(if_str); tfree(else_str); - if (beg_str != NULL) - tfree(beg_str); - if (end_str != NULL) - tfree(end_str); + tfree(beg_str); + tfree(end_str); return new_str; }