* various: Assume ISO C89-compliant free() implementation.
authorPaul Smith <psmith@gnu.org>
Fri, 25 Apr 2014 21:38:08 +0000 (17:38 -0400)
committerPaul Smith <psmith@gnu.org>
Mon, 7 Jul 2014 05:59:03 +0000 (01:59 -0400)
dir.c
expand.c
function.c
job.c
main.c
read.c
rule.c
variable.c
w32/subproc/sub_proc.c

diff --git a/dir.c b/dir.c
index 77b7bfeb0e07ab05a04ffeada6bff154c650b9e3..01373b3782f01a5aac7455897e599c25f057947b 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1172,13 +1172,6 @@ read_dirstream (__ptr_t stream)
   return 0;
 }
 
-static void
-ansi_free (void *p)
-{
-  if (p)
-    free (p);
-}
-
 /* On 64 bit ReliantUNIX (5.44 and above) in LFS mode, stat() is actually a
  * macro for stat64().  If stat is a macro, make a local wrapper function to
  * invoke it.
@@ -1224,7 +1217,7 @@ dir_setup_glob (glob_t *gl)
 {
   gl->gl_opendir = open_dirstream;
   gl->gl_readdir = read_dirstream;
-  gl->gl_closedir = ansi_free;
+  gl->gl_closedir = free;
   gl->gl_stat = local_stat;
   /* We don't bother setting gl_lstat, since glob never calls it.
      The slot is only there for compatibility with 4.4 BSD.  */
index 28ec198c515db00057f2d86dac573844a207ac25..e4b08f10f3492f70023cd859db734e87aed07ff3 100644 (file)
--- a/expand.c
+++ b/expand.c
@@ -377,7 +377,6 @@ variable_expand_string (char *line, const char *string, long length)
                  Look up the value of the variable.  */
                 o = reference_variable (o, beg, end - beg);
 
-          if (abeg)
             free (abeg);
           }
           break;
@@ -447,8 +446,7 @@ expand_argument (const char *str, const char *end)
 
   r = allocated_variable_expand (tmp);
 
-  if (alloc)
-    free (alloc);
+  free (alloc);
 
   return r;
 }
index bb62187d4f3562994dd9bcef75ee22eae1d20827..9c0a0363db9a34cd9d6e1a671c2132c40d494461 100644 (file)
@@ -2425,7 +2425,7 @@ handle_function (char **op, const char **stringp)
   if (entry_p->expand_args)
     for (argvp=argv; *argvp != 0; ++argvp)
       free (*argvp);
-  else if (abeg)
+  else
     free (abeg);
 
   return 1;
diff --git a/job.c b/job.c
index 1850fe13328a21bccb93d0bb7a8e6878d88e6a2f..f75c7f2e6ebdc206348fb10710b8963623f71573 100644 (file)
--- a/job.c
+++ b/job.c
@@ -2715,10 +2715,8 @@ construct_command_argv_internal (char *line, char **restp, const char *shell,
 
     slow_flag = strcmp ((s1 ? s1 : ""), (s2 ? s2 : ""));
 
-    if (s1)
-      free (s1);
-    if (s2)
-      free (s2);
+    free (s1);
+    free (s2);
   }
   if (slow_flag)
     goto slow;
diff --git a/main.c b/main.c
index 4659099e2ccb07e366c0b3825116116da57e7697..e5f7d388e59a4b23e5efab4191bff8dc345abdd4 100644 (file)
--- a/main.c
+++ b/main.c
@@ -996,8 +996,7 @@ find_and_set_default_shell (const char *token)
   batch_mode_shell = 1;
 #endif
 
-  if (atoken)
-    free (atoken);
+  free (atoken);
 
   return (sh_found);
 }
@@ -2405,9 +2404,8 @@ main (int argc, char **argv, char **envp)
 
       db_level = orig_db_level;
 
-      /* Free the makefile mtimes (if we allocated any).  */
-      if (makefile_mtimes)
-        free (makefile_mtimes);
+      /* Free the makefile mtimes.  */
+      free (makefile_mtimes);
     }
 
   /* Set up 'MAKEFLAGS' again for the normal targets.  */
@@ -2793,8 +2791,7 @@ decode_switches (int argc, const char **argv, int env)
                   if (cs->type == string)
                     {
                       char **val = (char **)cs->value_ptr;
-                      if (*val)
-                        free (*val);
+                      free (*val);
                       *val = xstrdup (coptarg);
                       break;
                     }
@@ -3365,11 +3362,8 @@ clean_jobserver (int status)
          sub-makes.  Also reset job_slots since it will be put on the command
          line, not in MAKEFLAGS.  */
       job_slots = default_job_slots;
-      if (jobserver_fds)
-        {
-          free (jobserver_fds);
-          jobserver_fds = 0;
-        }
+      free (jobserver_fds);
+      jobserver_fds = 0;
     }
 }
 \f
diff --git a/read.c b/read.c
index efacaf50336e7ce79c58ea1dc65ec90a3b9d2183..1fe229bb0b13f684585f70f51682e3a58c80ff69 100644 (file)
--- a/read.c
+++ b/read.c
@@ -307,10 +307,8 @@ static void
 restore_conditionals (struct conditionals *saved)
 {
   /* Free any space allocated by conditional_line.  */
-  if (conditionals->ignoring)
-    free (conditionals->ignoring);
-  if (conditionals->seen_else)
-    free (conditionals->seen_else);
+  free (conditionals->ignoring);
+  free (conditionals->seen_else);
 
   /* Restore state.  */
   conditionals = saved;
@@ -409,8 +407,7 @@ eval_makefile (const char *filename, int flags)
   if (flags & RM_DONTCARE)
     deps->dontcare = 1;
 
-  if (expanded)
-    free (expanded);
+  free (expanded);
 
   /* If the makefile can't be found at all, give up entirely.  */
 
@@ -707,8 +704,7 @@ eval (struct ebuffer *ebuf, int set_default)
       if (collapsed_length < linelen+1)
         {
           collapsed_length = linelen+1;
-          if (collapsed)
-            free (collapsed);
+          free (collapsed);
           /* Don't need xrealloc: we don't need to preserve the content.  */
           collapsed = xmalloc (collapsed_length);
         }
@@ -856,8 +852,7 @@ eval (struct ebuffer *ebuf, int set_default)
             /* No pattern means remove all previous selective VPATH's.  */
             vpat = 0;
           construct_vpath_list (vpat, p);
-          if (vpat != 0)
-            free (vpat);
+          free (vpat);
 
           continue;
         }
@@ -1401,8 +1396,7 @@ eval (struct ebuffer *ebuf, int set_default)
   /* At eof, record the last rule.  */
   record_waiting_files ();
 
-  if (collapsed)
-    free (collapsed);
+  free (collapsed);
   free (commands);
 }
 \f
@@ -1918,8 +1912,7 @@ record_target_var (struct nameseq *filenames, char *defn,
           if (gv && v != gv
               && (gv->origin == o_env_override || gv->origin == o_command))
             {
-              if (v->value != 0)
-                free (v->value);
+              free (v->value);
               v->value = xstrdup (gv->value);
               v->origin = gv->origin;
               v->recursive = gv->recursive;
@@ -2854,8 +2847,7 @@ construct_include_path (const char **arg_dirs)
             dirs[idx++] = strcache_add_len (dir, len);
           }
 
-        if (expanded)
-          free (expanded);
+        free (expanded);
       }
 
   /* Now add the standard default dirs at the end.  */
@@ -3347,12 +3339,10 @@ parse_file_seq (char **stringp, unsigned int size, int stopmap,
         globfree (&gl);
 
 #ifndef NO_ARCHIVES
-      if (arname)
-        free (arname);
+      free (arname);
 #endif
 
-      if (tildep)
-        free (tildep);
+      free (tildep);
     }
 
   *stringp = p;
diff --git a/rule.c b/rule.c
index 986ada74ec870ae25d08d2519e3280402d9733a8..2535bd6c641948799557aed1d99a5025cfc8dbc9 100644 (file)
--- a/rule.c
+++ b/rule.c
@@ -140,8 +140,7 @@ count_implicit_rule_limits (void)
       rule = next;
     }
 
-  if (name != 0)
-    free (name);
+  free (name);
 }
 \f
 /* Create a pattern rule from a suffix rule.
index 4df8d8dc3e93aa1d44e36013766aa61ac6578927..3f57e7db88d93f3fec959cad7d757df1be42eb8b 100644 (file)
@@ -222,8 +222,7 @@ define_variable_in_set (const char *name, unsigned int length,
          than this one, don't redefine it.  */
       if ((int) origin >= (int) v->origin)
         {
-          if (v->value != 0)
-            free (v->value);
+          free (v->value);
           v->value = xstrdup (value);
           if (flocp != 0)
             v->fileinfo = *flocp;
@@ -1233,8 +1232,7 @@ do_variable_definition (const gmk_floc *flocp, const char *varname,
             alloc_value[oldlen] = ' ';
             memcpy (&alloc_value[oldlen + 1], val, vallen + 1);
 
-            if (tp)
-              free (tp);
+            free (tp);
           }
       }
     }
@@ -1359,8 +1357,7 @@ do_variable_definition (const gmk_floc *flocp, const char *varname,
           else
             v = lookup_variable (varname, strlen (varname));
 
-          if (tp)
-            free (tp);
+          free (tp);
         }
     }
   else
@@ -1380,8 +1377,7 @@ do_variable_definition (const gmk_floc *flocp, const char *varname,
   v->append = append;
   v->conditional = conditional;
 
-  if (alloc_value)
-    free (alloc_value);
+  free (alloc_value);
 
   return v->special ? set_special_var (v) : v;
 }
@@ -1764,16 +1760,10 @@ sync_Path_environment (void)
   if (!path)
     return;
 
-  /*
-   * If done this before, don't leak memory unnecessarily.
-   * Free the previous entry before allocating new one.
-   */
-  if (environ_path)
-    free (environ_path);
+  /* If done this before, free the previous entry before allocating new one.  */
+  free (environ_path);
 
-  /*
-   * Create something WINDOWS32 world can grok
-   */
+  /* Create something WINDOWS32 world can grok.  */
   convert_Path_to_windows32 (path, ';');
   environ_path = xstrdup (concat (3, "PATH", "=", path));
   putenv (environ_path);
index 34cc85d2077c2f3dd86435f75371a829dbfca87c..88749daee09155587c8dfb373972085841095291 100644 (file)
@@ -767,7 +767,7 @@ process_begin(
         startInfo.hStdError = (HANDLE)pproc->sv_stderr[1];
 
         if (as_user) {
-                if (envblk) free(envblk);
+                free(envblk);
                 return -1;
         } else {
                 DB (DB_JOBS, ("CreateProcess(%s,%s,...)\n",
@@ -789,7 +789,7 @@ process_begin(
                         pproc->lerrno = E_FORK;
                         fprintf(stderr, "process_begin: CreateProcess(%s, %s, ...) failed.\n",
                                 exec_path ? exec_path : "NULL", command_line);
-                        if (envblk) free(envblk);
+                        free(envblk);
                         free( command_line );
                         return(-1);
                 }
@@ -811,7 +811,7 @@ process_begin(
         pproc->sv_stderr[1] = 0;
 
         free( command_line );
-        if (envblk) free(envblk);
+        free(envblk);
         pproc->lerrno=0;
         return 0;
 }
@@ -1320,7 +1320,7 @@ make_command_line( char *shell_name, char *full_exec_path, char **argv)
         command_line = (char*) malloc(bytes_required);
 
         if (!command_line) {
-                if (enclose_in_quotes) free(enclose_in_quotes);
+                free(enclose_in_quotes);
                 return NULL;
         }
 
@@ -1413,7 +1413,7 @@ make_command_line( char *shell_name, char *full_exec_path, char **argv)
          */
         *command_line_i = '\0';
 
-        if (enclose_in_quotes) free(enclose_in_quotes);
+        free(enclose_in_quotes);
         return command_line;
 }