diff options
author | Jim Meyering <meyering@redhat.com> | 2011-02-20 11:00:59 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-02-21 00:29:54 +0100 |
commit | 8678ae92eac4712eadeeb72cec1b53b395a0e546 (patch) | |
tree | aaf4a5025cf8bb246ab50b69256bc318f4b2b2fd | |
parent | e0f707523cab26f74ec23f4a20a27add8702ed5b (diff) | |
download | patch-8678ae92eac4712eadeeb72cec1b53b395a0e546.tar.gz |
maint: remove unnecessary tests before free
There is no longer any need to avoid "free(NULL)" (since SunOS 4),
so replace each "if (P) free (P);" with "free (P);".
* src/inp.c (get_input_file): Remove unnecessary test-before-free.
* src/patch.c (get_some_switches): Likewise.
* src/pch.c (intuit_diff_type, pch_swap): Likewise.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/inp.c | 3 | ||||
-rw-r--r-- | src/patch.c | 3 | ||||
-rw-r--r-- | src/pch.c | 21 |
4 files changed, 18 insertions, 18 deletions
@@ -1,3 +1,12 @@ +2011-02-20 Jim Meyering <meyering@redhat.com> + + maint: remove unnecessary tests before free + There is no longer any need to avoid "free(NULL)" (since SunOS 4), + so replace each "if (P) free (P);" with "free (P);". + * src/inp.c (get_input_file): Remove unnecessary test-before-free. + * src/patch.c (get_some_switches): Likewise. + * src/pch.c (intuit_diff_type, pch_swap): Likewise. + 2011-02-17 Jim Meyering <meyering@redhat.com> and Andreas Gruenbacher <agruen@linbit.com> @@ -186,8 +186,7 @@ get_input_file (char const *filename, char const *outname, mode_t mode) inerrno = 0; free (getbuf); - if (diffbuf) - free (diffbuf); + free (diffbuf); } if (inerrno) diff --git a/src/patch.c b/src/patch.c index 723a6e2..372e0f0 100644 --- a/src/patch.c +++ b/src/patch.c @@ -765,8 +765,7 @@ get_some_switches (void) { int optc; - if (rejname) - free (rejname); + free (rejname); rejname = 0; if (optind == Argc) return; @@ -901,8 +901,7 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) version_controlled[i] = 0; free (getbuf); - if (diffbuf) - free (diffbuf); + free (diffbuf); if (! stat_errno[i]) break; @@ -2027,14 +2026,11 @@ pch_swap (void) p_Char = 0; set_hunkmax(); if (!p_line || !p_len || !p_Char) { - if (p_line) - free (p_line); + free (p_line); p_line = tp_line; - if (p_len) - free (p_len); + free (p_len); p_len = tp_len; - if (p_Char) - free (p_Char); + free (p_Char); p_Char = tp_char; return false; /* not enough memory to swap hunk! */ } @@ -2093,12 +2089,9 @@ pch_swap (void) p_ptrn_lines = p_repl_lines; p_repl_lines = i; p_Char[p_end + 1] = '^'; - if (tp_line) - free (tp_line); - if (tp_len) - free (tp_len); - if (tp_char) - free (tp_char); + free (tp_line); + free (tp_len); + free (tp_char); return true; } |