From 12d24222db486f97696258dc0fd8df05c8d5de7f Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Fri, 24 Sep 2004 22:37:00 +0000 Subject: [PATCH] * edit.c (edit_clean): g_free handles NULL argument too, no need for the comparison. (edit_move_backward_lots): Likewise. * editcmd.c (edit_set_filename): Likewise. (edit_replace_cmd): Likewise. (edit_search_cmd): Likewise. (edit_sort_cmd): Likewise. (edit_mail_dialog): Likewise. * syntax.c (syntax_g_free): Likewise. (edit_read_syntax_rules): Likewise. --- edit/ChangeLog | 13 +++++++++++++ edit/edit.c | 9 +++------ edit/editcmd.c | 42 ++++++++++++++---------------------------- edit/syntax.c | 5 ++--- 4 files changed, 32 insertions(+), 37 deletions(-) diff --git a/edit/ChangeLog b/edit/ChangeLog index 8b5a634aa..4fc156212 100644 --- a/edit/ChangeLog +++ b/edit/ChangeLog @@ -1,3 +1,16 @@ +2004-09-25 Pavel S. Shirshov + + * edit.c (edit_clean): g_free handles NULL argument too, + no need for the comparison. + (edit_move_backward_lots): Likewise. + * editcmd.c (edit_set_filename): Likewise. + (edit_replace_cmd): Likewise. + (edit_search_cmd): Likewise. + (edit_sort_cmd): Likewise. + (edit_mail_dialog): Likewise. + * syntax.c (syntax_g_free): Likewise. + (edit_read_syntax_rules): Likewise. + 2004-09-24 Roland Illig * editdraw.c (status_string): Removed unused parameter. diff --git a/edit/edit.c b/edit/edit.c index 0d6be4d2b..6c27c8cb3 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -593,10 +593,8 @@ edit_clean (WEdit *edit) edit_free_syntax_rules (edit); book_mark_flush (edit, -1); for (; j <= MAXBUFF; j++) { - if (edit->buffers1[j] != NULL) - g_free (edit->buffers1[j]); - if (edit->buffers2[j] != NULL) - g_free (edit->buffers2[j]); + g_free (edit->buffers1[j]); + g_free (edit->buffers2[j]); } g_free (edit->undo_stack); @@ -1053,8 +1051,7 @@ edit_move_backward_lots (WEdit *edit, long increment) edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE); } else { - if (p) - g_free (p); + g_free (p); } s = edit->curs1 & M_EDIT_BUF_SIZE; diff --git a/edit/editcmd.c b/edit/editcmd.c index 1d42d35cd..0efe19f5a 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -440,8 +440,7 @@ void menu_save_mode_cmd (void) void edit_set_filename (WEdit *edit, const char *f) { - if (edit->filename) - g_free (edit->filename); + g_free (edit->filename); if (!f) f = ""; edit->filename = g_strdup (f); @@ -1759,18 +1758,12 @@ edit_replace_cmd (WEdit *edit, int again) int argord[NUM_REPL_ARGS]; if (!edit) { - if (old1) { - g_free (old1); - old1 = 0; - } - if (old2) { - g_free (old2); - old2 = 0; - } - if (old3) { - g_free (old3); - old3 = 0; - } + g_free (old1); + old1 = 0; + g_free (old2); + old2 = 0; + g_free (old3); + old3 = 0; return; } last_search = edit->last_byte; @@ -2008,10 +2001,8 @@ void edit_search_cmd (WEdit * edit, int again) char *exp = ""; if (!edit) { - if (old) { - g_free (old); - old = 0; - } + g_free (old); + old = 0; return; } exp = old ? old : exp; @@ -2039,8 +2030,7 @@ void edit_search_cmd (WEdit * edit, int again) if (exp) { if (*exp) { int len = 0; - if (old) - g_free (old); + g_free (old); old = g_strdup (exp); if (search_create_bookmark) { @@ -2378,8 +2368,7 @@ int edit_sort_cmd (WEdit * edit) if (!exp) return 1; - if (old) - g_free (old); + g_free (old); old = exp; e = system (catstrs (" sort ", exp, " ", home_dir, BLOCK_FILE, " > ", home_dir, TEMP_FILE, (char *) NULL)); @@ -2624,12 +2613,9 @@ void edit_mail_dialog (WEdit * edit) Quick_input.widgets = quick_widgets; if (quick_dialog (&Quick_input) != B_CANCEL) { - if (mail_cc_last) - g_free (mail_cc_last); - if (mail_subject_last) - g_free (mail_subject_last); - if (mail_to_last) - g_free (mail_to_last); + g_free (mail_cc_last); + g_free (mail_subject_last); + g_free (mail_to_last); mail_cc_last = tmail_cc; mail_subject_last = tmail_subject; mail_to_last = tmail_to; diff --git a/edit/syntax.c b/edit/syntax.c index e2e8eb1a9..cdb6944d3 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -86,7 +86,7 @@ struct _syntax_marker { int option_syntax_highlighting = 1; -#define syntax_g_free(x) do {if(x) {g_free(x); (x)=0;}} while (0) +#define syntax_g_free(x) do {g_free(x); (x)=0;} while (0) static gint mc_defines_destroy (gpointer key, gpointer value, gpointer data) @@ -673,8 +673,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args) g = 0; line = save_line + 1; syntax_g_free (error_file_name); - if (l) - syntax_g_free (l); + syntax_g_free (l); if (!read_one_line (&l, f)) break; } else {