aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorJim Meyering <meyering@gcc.gnu.org>2011-04-20 18:19:03 +0000
committerJim Meyering <meyering@gcc.gnu.org>2011-04-20 18:19:03 +0000
commit046957830e176ad16fdef39bc7f1cd44d8fbc3b7 (patch)
treee56a024bf4863c42aaa3f941f466a849bb9d3b82 /libcpp
parent53eebfbf949c9cfe6a060a91a09242cb7204f6d8 (diff)
downloadgcc-046957830e176ad16fdef39bc7f1cd44d8fbc3b7.zip
gcc-046957830e176ad16fdef39bc7f1cd44d8fbc3b7.tar.gz
gcc-046957830e176ad16fdef39bc7f1cd44d8fbc3b7.tar.bz2
remove useless if-before-free tests
Change "if (E) free (E);" to "free (E);" everywhere except in the libgo/, intl/, zlib/ and classpath/ directories. Also transform equivalent variants like "if (E != NULL) free (E);" and allow an extra cast on the argument to free. Otherwise, the tested and freed "E" expressions must be identical, modulo white space. From-SVN: r172785
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog7
-rw-r--r--libcpp/files.c3
-rw-r--r--libcpp/init.c3
-rw-r--r--libcpp/macro.c3
-rw-r--r--libcpp/pch.c9
5 files changed, 13 insertions, 12 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index cfd07d4..eb93719e 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,10 @@
+2011-04-20 Jim Meyering <meyering@redhat.com>
+
+ * files.c (destroy_cpp_file): Remove useless if-before-free.
+ * init.c (cpp_destroy): Likewise.
+ * macro.c (replace_args): Likewise.
+ * pch.c (cpp_valid_state): Likewise.
+
2011-03-25 Kai Tietz <ktietz@redhat.com>
* files.c (file_hash_eq): Use filename_cmp
diff --git a/libcpp/files.c b/libcpp/files.c
index e3cff49..cd0bc48 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -996,8 +996,7 @@ make_cpp_file (cpp_reader *pfile, cpp_dir *dir, const char *fname)
static void
destroy_cpp_file (_cpp_file *file)
{
- if (file->buffer_start)
- free ((void *) file->buffer_start);
+ free ((void *) file->buffer_start);
free ((void *) file->name);
free (file);
}
diff --git a/libcpp/init.c b/libcpp/init.c
index 5c6dacf..5ba6666 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -259,8 +259,7 @@ cpp_destroy (cpp_reader *pfile)
while (CPP_BUFFER (pfile) != NULL)
_cpp_pop_buffer (pfile);
- if (pfile->out.base)
- free (pfile->out.base);
+ free (pfile->out.base);
if (pfile->macro_buffer)
{
diff --git a/libcpp/macro.c b/libcpp/macro.c
index d9324a3..eba2349 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -1064,8 +1064,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, macro_arg
/* Free the expanded arguments. */
for (i = 0; i < macro->paramc; i++)
- if (args[i].expanded)
- free (args[i].expanded);
+ free (args[i].expanded);
push_ptoken_context (pfile, node, buff, first, dest - first);
}
diff --git a/libcpp/pch.c b/libcpp/pch.c
index 00b7794..d278f14 100644
--- a/libcpp/pch.c
+++ b/libcpp/pch.c
@@ -713,12 +713,9 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
return -1;
fail:
- if (namebuf != NULL)
- free (namebuf);
- if (undeftab != NULL)
- free (undeftab);
- if (nl.defs != NULL)
- free (nl.defs);
+ free (namebuf);
+ free (undeftab);
+ free (nl.defs);
return 1;
}