Change if(x)free(x); to free(x);

This commit is contained in:
Aaron Lehmann
2002-11-28 11:27:31 +00:00
parent 1652855fbc
commit a170e1c858
16 changed files with 47 additions and 95 deletions

View File

@@ -810,7 +810,7 @@ static void b_reset(o_string *o)
static void b_free(o_string *o)
{
b_reset(o);
if (o->data != NULL) free(o->data);
free(o->data);
o->data = NULL;
o->maxlen = 0;
}
@@ -880,8 +880,7 @@ static inline void setup_prompt_string(int promptmode, char **prompt_str)
#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
/* Set up the prompt */
if (promptmode == 1) {
if (PS1)
free(PS1);
free(PS1);
PS1=xmalloc(strlen(cwd)+4);
sprintf(PS1, "%s %s", cwd, ( geteuid() != 0 ) ? "$ ":"# ");
*prompt_str = PS1;

View File

@@ -518,12 +518,9 @@ static void free_job(struct job *cmd)
if (cmd->progs[i].redirects)
free(cmd->progs[i].redirects);
}
if (cmd->progs)
free(cmd->progs);
if (cmd->text)
free(cmd->text);
if (cmd->cmdbuf)
free(cmd->cmdbuf);
free(cmd->progs);
free(cmd->text);
free(cmd->cmdbuf);
keep = cmd->job_list;
memset(cmd, 0, sizeof(struct job));
cmd->job_list = keep;
@@ -677,8 +674,7 @@ static inline void setup_prompt_string(char **prompt_str)
#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
/* Set up the prompt */
if (shell_context == 0) {
if (PS1)
free(PS1);
free(PS1);
PS1=xmalloc(strlen(cwd)+4);
sprintf(PS1, "%s %s", cwd, ( geteuid() != 0 ) ? "$ ":"# ");
*prompt_str = PS1;