summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-02-20 11:00:59 +0100
committerJim Meyering <meyering@redhat.com>2011-02-21 00:29:54 +0100
commit8678ae92eac4712eadeeb72cec1b53b395a0e546 (patch)
treeaaf4a5025cf8bb246ab50b69256bc318f4b2b2fd
parente0f707523cab26f74ec23f4a20a27add8702ed5b (diff)
downloadpatch-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--ChangeLog9
-rw-r--r--src/inp.c3
-rw-r--r--src/patch.c3
-rw-r--r--src/pch.c21
4 files changed, 18 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 046df0e..77fb4d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/src/inp.c b/src/inp.c
index 28c548d..af5bfd0 100644
--- a/src/inp.c
+++ b/src/inp.c
@@ -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;
diff --git a/src/pch.c b/src/pch.c
index 1fd3848..b25424f 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -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;
}