mirror of
https://github.com/mirror/make.git
synced 2025-02-25 19:30:48 +08:00
* various: Assume ISO C89-compliant free() implementation.
This commit is contained in:
parent
ac67346d0f
commit
423c3955d9
9
dir.c
9
dir.c
@ -1172,13 +1172,6 @@ read_dirstream (__ptr_t stream)
|
|||||||
return 0;
|
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
|
/* 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
|
* macro for stat64(). If stat is a macro, make a local wrapper function to
|
||||||
* invoke it.
|
* invoke it.
|
||||||
@ -1224,7 +1217,7 @@ dir_setup_glob (glob_t *gl)
|
|||||||
{
|
{
|
||||||
gl->gl_opendir = open_dirstream;
|
gl->gl_opendir = open_dirstream;
|
||||||
gl->gl_readdir = read_dirstream;
|
gl->gl_readdir = read_dirstream;
|
||||||
gl->gl_closedir = ansi_free;
|
gl->gl_closedir = free;
|
||||||
gl->gl_stat = local_stat;
|
gl->gl_stat = local_stat;
|
||||||
/* We don't bother setting gl_lstat, since glob never calls it.
|
/* We don't bother setting gl_lstat, since glob never calls it.
|
||||||
The slot is only there for compatibility with 4.4 BSD. */
|
The slot is only there for compatibility with 4.4 BSD. */
|
||||||
|
4
expand.c
4
expand.c
@ -377,7 +377,6 @@ variable_expand_string (char *line, const char *string, long length)
|
|||||||
Look up the value of the variable. */
|
Look up the value of the variable. */
|
||||||
o = reference_variable (o, beg, end - beg);
|
o = reference_variable (o, beg, end - beg);
|
||||||
|
|
||||||
if (abeg)
|
|
||||||
free (abeg);
|
free (abeg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -447,8 +446,7 @@ expand_argument (const char *str, const char *end)
|
|||||||
|
|
||||||
r = allocated_variable_expand (tmp);
|
r = allocated_variable_expand (tmp);
|
||||||
|
|
||||||
if (alloc)
|
free (alloc);
|
||||||
free (alloc);
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -2425,7 +2425,7 @@ handle_function (char **op, const char **stringp)
|
|||||||
if (entry_p->expand_args)
|
if (entry_p->expand_args)
|
||||||
for (argvp=argv; *argvp != 0; ++argvp)
|
for (argvp=argv; *argvp != 0; ++argvp)
|
||||||
free (*argvp);
|
free (*argvp);
|
||||||
else if (abeg)
|
else
|
||||||
free (abeg);
|
free (abeg);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
6
job.c
6
job.c
@ -2715,10 +2715,8 @@ construct_command_argv_internal (char *line, char **restp, const char *shell,
|
|||||||
|
|
||||||
slow_flag = strcmp ((s1 ? s1 : ""), (s2 ? s2 : ""));
|
slow_flag = strcmp ((s1 ? s1 : ""), (s2 ? s2 : ""));
|
||||||
|
|
||||||
if (s1)
|
free (s1);
|
||||||
free (s1);
|
free (s2);
|
||||||
if (s2)
|
|
||||||
free (s2);
|
|
||||||
}
|
}
|
||||||
if (slow_flag)
|
if (slow_flag)
|
||||||
goto slow;
|
goto slow;
|
||||||
|
18
main.c
18
main.c
@ -996,8 +996,7 @@ find_and_set_default_shell (const char *token)
|
|||||||
batch_mode_shell = 1;
|
batch_mode_shell = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (atoken)
|
free (atoken);
|
||||||
free (atoken);
|
|
||||||
|
|
||||||
return (sh_found);
|
return (sh_found);
|
||||||
}
|
}
|
||||||
@ -2405,9 +2404,8 @@ main (int argc, char **argv, char **envp)
|
|||||||
|
|
||||||
db_level = orig_db_level;
|
db_level = orig_db_level;
|
||||||
|
|
||||||
/* Free the makefile mtimes (if we allocated any). */
|
/* Free the makefile mtimes. */
|
||||||
if (makefile_mtimes)
|
free (makefile_mtimes);
|
||||||
free (makefile_mtimes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up 'MAKEFLAGS' again for the normal targets. */
|
/* 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)
|
if (cs->type == string)
|
||||||
{
|
{
|
||||||
char **val = (char **)cs->value_ptr;
|
char **val = (char **)cs->value_ptr;
|
||||||
if (*val)
|
free (*val);
|
||||||
free (*val);
|
|
||||||
*val = xstrdup (coptarg);
|
*val = xstrdup (coptarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3365,11 +3362,8 @@ clean_jobserver (int status)
|
|||||||
sub-makes. Also reset job_slots since it will be put on the command
|
sub-makes. Also reset job_slots since it will be put on the command
|
||||||
line, not in MAKEFLAGS. */
|
line, not in MAKEFLAGS. */
|
||||||
job_slots = default_job_slots;
|
job_slots = default_job_slots;
|
||||||
if (jobserver_fds)
|
free (jobserver_fds);
|
||||||
{
|
jobserver_fds = 0;
|
||||||
free (jobserver_fds);
|
|
||||||
jobserver_fds = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
read.c
30
read.c
@ -307,10 +307,8 @@ static void
|
|||||||
restore_conditionals (struct conditionals *saved)
|
restore_conditionals (struct conditionals *saved)
|
||||||
{
|
{
|
||||||
/* Free any space allocated by conditional_line. */
|
/* Free any space allocated by conditional_line. */
|
||||||
if (conditionals->ignoring)
|
free (conditionals->ignoring);
|
||||||
free (conditionals->ignoring);
|
free (conditionals->seen_else);
|
||||||
if (conditionals->seen_else)
|
|
||||||
free (conditionals->seen_else);
|
|
||||||
|
|
||||||
/* Restore state. */
|
/* Restore state. */
|
||||||
conditionals = saved;
|
conditionals = saved;
|
||||||
@ -409,8 +407,7 @@ eval_makefile (const char *filename, int flags)
|
|||||||
if (flags & RM_DONTCARE)
|
if (flags & RM_DONTCARE)
|
||||||
deps->dontcare = 1;
|
deps->dontcare = 1;
|
||||||
|
|
||||||
if (expanded)
|
free (expanded);
|
||||||
free (expanded);
|
|
||||||
|
|
||||||
/* If the makefile can't be found at all, give up entirely. */
|
/* 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)
|
if (collapsed_length < linelen+1)
|
||||||
{
|
{
|
||||||
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. */
|
/* Don't need xrealloc: we don't need to preserve the content. */
|
||||||
collapsed = xmalloc (collapsed_length);
|
collapsed = xmalloc (collapsed_length);
|
||||||
}
|
}
|
||||||
@ -856,8 +852,7 @@ eval (struct ebuffer *ebuf, int set_default)
|
|||||||
/* No pattern means remove all previous selective VPATH's. */
|
/* No pattern means remove all previous selective VPATH's. */
|
||||||
vpat = 0;
|
vpat = 0;
|
||||||
construct_vpath_list (vpat, p);
|
construct_vpath_list (vpat, p);
|
||||||
if (vpat != 0)
|
free (vpat);
|
||||||
free (vpat);
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1401,8 +1396,7 @@ eval (struct ebuffer *ebuf, int set_default)
|
|||||||
/* At eof, record the last rule. */
|
/* At eof, record the last rule. */
|
||||||
record_waiting_files ();
|
record_waiting_files ();
|
||||||
|
|
||||||
if (collapsed)
|
free (collapsed);
|
||||||
free (collapsed);
|
|
||||||
free (commands);
|
free (commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1918,8 +1912,7 @@ record_target_var (struct nameseq *filenames, char *defn,
|
|||||||
if (gv && v != gv
|
if (gv && v != gv
|
||||||
&& (gv->origin == o_env_override || gv->origin == o_command))
|
&& (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->value = xstrdup (gv->value);
|
||||||
v->origin = gv->origin;
|
v->origin = gv->origin;
|
||||||
v->recursive = gv->recursive;
|
v->recursive = gv->recursive;
|
||||||
@ -2854,8 +2847,7 @@ construct_include_path (const char **arg_dirs)
|
|||||||
dirs[idx++] = strcache_add_len (dir, len);
|
dirs[idx++] = strcache_add_len (dir, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expanded)
|
free (expanded);
|
||||||
free (expanded);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now add the standard default dirs at the end. */
|
/* 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);
|
globfree (&gl);
|
||||||
|
|
||||||
#ifndef NO_ARCHIVES
|
#ifndef NO_ARCHIVES
|
||||||
if (arname)
|
free (arname);
|
||||||
free (arname);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tildep)
|
free (tildep);
|
||||||
free (tildep);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*stringp = p;
|
*stringp = p;
|
||||||
|
3
rule.c
3
rule.c
@ -140,8 +140,7 @@ count_implicit_rule_limits (void)
|
|||||||
rule = next;
|
rule = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name != 0)
|
free (name);
|
||||||
free (name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a pattern rule from a suffix rule.
|
/* Create a pattern rule from a suffix rule.
|
||||||
|
24
variable.c
24
variable.c
@ -222,8 +222,7 @@ define_variable_in_set (const char *name, unsigned int length,
|
|||||||
than this one, don't redefine it. */
|
than this one, don't redefine it. */
|
||||||
if ((int) origin >= (int) v->origin)
|
if ((int) origin >= (int) v->origin)
|
||||||
{
|
{
|
||||||
if (v->value != 0)
|
free (v->value);
|
||||||
free (v->value);
|
|
||||||
v->value = xstrdup (value);
|
v->value = xstrdup (value);
|
||||||
if (flocp != 0)
|
if (flocp != 0)
|
||||||
v->fileinfo = *flocp;
|
v->fileinfo = *flocp;
|
||||||
@ -1233,8 +1232,7 @@ do_variable_definition (const gmk_floc *flocp, const char *varname,
|
|||||||
alloc_value[oldlen] = ' ';
|
alloc_value[oldlen] = ' ';
|
||||||
memcpy (&alloc_value[oldlen + 1], val, vallen + 1);
|
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
|
else
|
||||||
v = lookup_variable (varname, strlen (varname));
|
v = lookup_variable (varname, strlen (varname));
|
||||||
|
|
||||||
if (tp)
|
free (tp);
|
||||||
free (tp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1380,8 +1377,7 @@ do_variable_definition (const gmk_floc *flocp, const char *varname,
|
|||||||
v->append = append;
|
v->append = append;
|
||||||
v->conditional = conditional;
|
v->conditional = conditional;
|
||||||
|
|
||||||
if (alloc_value)
|
free (alloc_value);
|
||||||
free (alloc_value);
|
|
||||||
|
|
||||||
return v->special ? set_special_var (v) : v;
|
return v->special ? set_special_var (v) : v;
|
||||||
}
|
}
|
||||||
@ -1764,16 +1760,10 @@ sync_Path_environment (void)
|
|||||||
if (!path)
|
if (!path)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/* If done this before, free the previous entry before allocating new one. */
|
||||||
* If done this before, don't leak memory unnecessarily.
|
free (environ_path);
|
||||||
* Free the previous entry before allocating new one.
|
|
||||||
*/
|
|
||||||
if (environ_path)
|
|
||||||
free (environ_path);
|
|
||||||
|
|
||||||
/*
|
/* Create something WINDOWS32 world can grok. */
|
||||||
* Create something WINDOWS32 world can grok
|
|
||||||
*/
|
|
||||||
convert_Path_to_windows32 (path, ';');
|
convert_Path_to_windows32 (path, ';');
|
||||||
environ_path = xstrdup (concat (3, "PATH", "=", path));
|
environ_path = xstrdup (concat (3, "PATH", "=", path));
|
||||||
putenv (environ_path);
|
putenv (environ_path);
|
||||||
|
@ -767,7 +767,7 @@ process_begin(
|
|||||||
startInfo.hStdError = (HANDLE)pproc->sv_stderr[1];
|
startInfo.hStdError = (HANDLE)pproc->sv_stderr[1];
|
||||||
|
|
||||||
if (as_user) {
|
if (as_user) {
|
||||||
if (envblk) free(envblk);
|
free(envblk);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
DB (DB_JOBS, ("CreateProcess(%s,%s,...)\n",
|
DB (DB_JOBS, ("CreateProcess(%s,%s,...)\n",
|
||||||
@ -789,7 +789,7 @@ process_begin(
|
|||||||
pproc->lerrno = E_FORK;
|
pproc->lerrno = E_FORK;
|
||||||
fprintf(stderr, "process_begin: CreateProcess(%s, %s, ...) failed.\n",
|
fprintf(stderr, "process_begin: CreateProcess(%s, %s, ...) failed.\n",
|
||||||
exec_path ? exec_path : "NULL", command_line);
|
exec_path ? exec_path : "NULL", command_line);
|
||||||
if (envblk) free(envblk);
|
free(envblk);
|
||||||
free( command_line );
|
free( command_line );
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -811,7 +811,7 @@ process_begin(
|
|||||||
pproc->sv_stderr[1] = 0;
|
pproc->sv_stderr[1] = 0;
|
||||||
|
|
||||||
free( command_line );
|
free( command_line );
|
||||||
if (envblk) free(envblk);
|
free(envblk);
|
||||||
pproc->lerrno=0;
|
pproc->lerrno=0;
|
||||||
return 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);
|
command_line = (char*) malloc(bytes_required);
|
||||||
|
|
||||||
if (!command_line) {
|
if (!command_line) {
|
||||||
if (enclose_in_quotes) free(enclose_in_quotes);
|
free(enclose_in_quotes);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1413,7 +1413,7 @@ make_command_line( char *shell_name, char *full_exec_path, char **argv)
|
|||||||
*/
|
*/
|
||||||
*command_line_i = '\0';
|
*command_line_i = '\0';
|
||||||
|
|
||||||
if (enclose_in_quotes) free(enclose_in_quotes);
|
free(enclose_in_quotes);
|
||||||
return command_line;
|
return command_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user