summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Lehmann2002-11-28 11:27:31 +0000
committerAaron Lehmann2002-11-28 11:27:31 +0000
commita170e1c858d35c474ceb9fecb41b37d681424094 (patch)
treecda2b13f10ca1ab0a3559d4b6ff663ed20d7106c
parent1652855fbc830f41c7ee56ece1a30b328c4fb395 (diff)
downloadbusybox-a170e1c858d35c474ceb9fecb41b37d681424094.zip
busybox-a170e1c858d35c474ceb9fecb41b37d681424094.tar.gz
Change if(x)free(x); to free(x);
-rw-r--r--archival/dpkg.c28
-rw-r--r--archival/gzip.c2
-rw-r--r--coreutils/ls.c3
-rw-r--r--editors/awk.c9
-rw-r--r--editors/sed.c3
-rw-r--r--editors/vi.c39
-rw-r--r--findutils/grep.c6
-rw-r--r--libpwdgrp/__getgrent.c3
-rw-r--r--modutils/insmod.c7
-rw-r--r--networking/udhcp/dhcpc.c4
-rw-r--r--networking/udhcp/files.c2
-rw-r--r--shell/hush.c5
-rw-r--r--shell/lash.c12
-rw-r--r--util-linux/fsck_minix.c4
-rw-r--r--util-linux/getopt.c9
-rw-r--r--util-linux/umount.c6
16 files changed, 47 insertions, 95 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 8b25bac..23509fc 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -491,13 +491,9 @@ void free_package(common_node_t *node)
unsigned short i;
if (node) {
for (i = 0; i < node->num_of_edges; i++) {
- if (node->edge[i]) {
- free(node->edge[i]);
- }
- }
- if (node->edge) {
- free(node->edge);
+ free(node->edge[i]);
}
+ free(node->edge);
free(node);
}
}
@@ -571,12 +567,8 @@ unsigned int fill_package_struct(char *control_buffer)
break;
}
fill_package_struct_cleanup:
- if (field_name) {
- free(field_name);
- }
- if (field_value) {
- free(field_value);
- }
+ free(field_name);
+ free(field_value);
}
if (new_node->version == search_name_hashtable("unknown")) {
@@ -880,9 +872,7 @@ void write_status_file(deb_file_t **deb_file)
fprintf(new_status_file, "%s\n\n", control_buffer);
}
- if (status_from_file != NULL) {
- free(status_from_file);
- }
+ free(status_from_file);
free(package_name);
free(control_buffer);
}
@@ -1661,9 +1651,7 @@ int dpkg_main(int argc, char **argv)
free(deb_file);
for (i = 0; i < NAME_HASH_PRIME; i++) {
- if (name_hashtable[i] != NULL) {
- free(name_hashtable[i]);
- }
+ free(name_hashtable[i]);
}
for (i = 0; i < PACKAGE_HASH_PRIME; i++) {
@@ -1673,9 +1661,7 @@ int dpkg_main(int argc, char **argv)
}
for (i = 0; i < STATUS_HASH_PRIME; i++) {
- if (status_hashtable[i] != NULL) {
- free(status_hashtable[i]);
- }
+ free(status_hashtable[i]);
}
return(EXIT_SUCCESS);
diff --git a/archival/gzip.c b/archival/gzip.c
index da93157..971724d 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -111,7 +111,7 @@ typedef unsigned long ulg;
# define ALLOC(type, array, size) { \
array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
}
-# define FREE(array) {if (array != NULL) free(array), array=NULL;}
+# define FREE(array) {free(array), array=NULL;}
#else
# define DECLARE(type, array, size) static type array[size]
# define ALLOC(type, array, size)
diff --git a/coreutils/ls.c b/coreutils/ls.c
index d2a935d..853a180 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -360,8 +360,7 @@ static void dfree(struct dnode **dnp)
cur = dnp[0];
while (cur != NULL) {
- if (cur->fullname != NULL)
- free(cur->fullname); /* free the filename */
+ free(cur->fullname); /* free the filename */
next = cur->next;
free(cur); /* free the dnode */
cur = next;
diff --git a/editors/awk.c b/editors/awk.c
index aea852b..44c2f45 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -650,7 +650,7 @@ static void clear_array(xhash *array) {
while (hi) {
thi = hi;
hi = hi->next;
- if (thi->data.v.string) free(thi->data.v.string);
+ free(thi->data.v.string);
free(thi);
}
array->items[i] = NULL;
@@ -661,7 +661,7 @@ static void clear_array(xhash *array) {
/* clear a variable */
static var *clrvar(var *v) {
- if (v->string && !(v->type & VF_FSTR))
+ if (!(v->type & VF_FSTR))
free(v->string);
v->type &= VF_DONTTOUCH;
@@ -1504,7 +1504,7 @@ static void split_f0(void) {
return;
is_f0_split = TRUE;
- if (fstrings) free(fstrings);
+ free(fstrings);
fsrealloc(0);
n = awk_split(getvar_s(V[F0]), &fsplitter.n, &fstrings);
fsrealloc(n);
@@ -2376,8 +2376,7 @@ re_cont:
X.rsm = (rstream *)hash_search(fdhash, L.s);
if (X.rsm) {
R.i = X.rsm->is_pipe ? pclose(X.rsm->F) : fclose(X.rsm->F);
- if (X.rsm->buffer)
- free(X.rsm->buffer);
+ free(X.rsm->buffer);
hash_remove(fdhash, L.s);
}
if (R.i != 0)
diff --git a/editors/sed.c b/editors/sed.c
index 23e9d54..df62346 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -130,8 +130,7 @@ static void destroy_cmd_strs(void)
regfree(sed_cmds[ncmds].sub_match);
free(sed_cmds[ncmds].sub_match);
}
- if (sed_cmds[ncmds].replace)
- free(sed_cmds[ncmds].replace);
+ free(sed_cmds[ncmds].replace);
}
/* destroy the array */
diff --git a/editors/vi.c b/editors/vi.c
index 1275d13..835adb6 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -19,7 +19,7 @@
*/
static const char vi_Version[] =
- "$Id: vi.c,v 1.24 2002/10/26 10:19:19 andersen Exp $";
+ "$Id: vi.c,v 1.25 2002/11/28 11:27:23 aaronl Exp $";
/*
* To compile for standalone use:
@@ -383,8 +383,7 @@ extern int vi_main(int argc, char **argv)
} else {
for (; optind < argc; optind++) {
editing = 1; // 0=exit, 1=one file, 2+ =many files
- if (cfn != 0)
- free(cfn);
+ free(cfn);
cfn = (Byte *) xstrdup(argv[optind]);
edit_file(cfn);
}
@@ -490,10 +489,8 @@ static void edit_file(Byte * fn)
offset = 0; // no horizontal offset
c = '\0';
#ifdef CONFIG_FEATURE_VI_DOT_CMD
- if (last_modifying_cmd != 0)
- free(last_modifying_cmd);
- if (ioq_start != NULL)
- free(ioq_start);
+ free(last_modifying_cmd);
+ free(ioq_start);
ioq = ioq_start = last_modifying_cmd = 0;
adding2q = 0;
#endif /* CONFIG_FEATURE_VI_DOT_CMD */
@@ -998,8 +995,7 @@ static void colon(Byte * buf)
// There is a read-able regular file
// make this the current file
q = (Byte *) xstrdup((char *) fn); // save the cfn
- if (cfn != 0)
- free(cfn); // free the old name
+ free(cfn); // free the old name
cfn = q; // remember new cfn
vc5:
@@ -1048,8 +1044,7 @@ static void colon(Byte * buf)
}
if (strlen((char *) args) > 0) {
// user wants a new filename
- if (cfn != NULL)
- free(cfn);
+ free(cfn);
cfn = (Byte *) xstrdup((char *) args);
} else {
// user wants file status info
@@ -1635,8 +1630,7 @@ static Byte *new_screen(int ro, int co)
{
int li;
- if (screen != 0)
- free(screen);
+ free(screen);
screensize = ro * co + 8;
screen = (Byte *) xmalloc(screensize);
// initialize the new screen. assume this will be a empty file.
@@ -1652,10 +1646,7 @@ static Byte *new_text(int size)
{
if (size < 10240)
size = 10240; // have a minimum size for new files
- if (text != 0) {
- //text -= 4;
- free(text);
- }
+ free(text);
text = (Byte *) xmalloc(size + 8);
memset(text, '\0', size); // clear new text[]
//text += 4; // leave some room for "oops"
@@ -2171,8 +2162,7 @@ extern inline void print_literal(Byte * buf, Byte * s) // copy s to buf, convert
static void start_new_cmd_q(Byte c)
{
// release old cmd
- if (last_modifying_cmd != 0)
- free(last_modifying_cmd);
+ free(last_modifying_cmd);
// get buffer for new cmd
last_modifying_cmd = (Byte *) xmalloc(BUFSIZ);
memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue
@@ -2227,9 +2217,7 @@ static Byte *text_yank(Byte * p, Byte * q, int dest) // copy text into a registe
}
cnt = q - p + 1;
t = reg[dest];
- if (t != 0) { // if already a yank register
- free(t); // free it
- }
+ free(t); // if already a yank register, free it
t = (Byte *) xmalloc(cnt + 1); // get a new register
memset(t, '\0', cnt + 1); // clear new text[]
strncpy((char *) t, (char *) p, cnt); // copy text[] into bufer
@@ -2615,8 +2603,7 @@ static Byte *get_input_line(Byte * prompt) // get input line- use "status line"
}
}
refresh(FALSE);
- if (obufp != NULL)
- free(obufp);
+ free(obufp);
obufp = (Byte *) xstrdup((char *) buf);
return (obufp);
}
@@ -3454,9 +3441,7 @@ key_cmd_mode:
goto dc3; // if no pat re-use old pat
if (strlen((char *) q) > 1) { // new pat- save it and find
// there is a new pat
- if (last_search_pattern != 0) {
- free(last_search_pattern);
- }
+ free(last_search_pattern);
last_search_pattern = (Byte *) xstrdup((char *) q);
goto dc3; // now find the pattern
}
diff --git a/findutils/grep.c b/findutils/grep.c
index 6fe1833..cc2b697 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -153,8 +153,7 @@ static void grep_file(FILE *file)
else { /* no match */
/* Add the line to the circular 'before' buffer */
if(lines_before) {
- if(before_buf[curpos])
- free(before_buf[curpos]);
+ free(before_buf[curpos]);
before_buf[curpos] = xstrdup(line);
curpos = (curpos + 1) % lines_before;
}
@@ -225,8 +224,7 @@ static void destroy_regexes(void)
while (--nregexes >= 0) {
regfree(&(regexes[nregexes]));
}
- if (regexes)
- free(regexes);
+ free(regexes);
}
#endif
diff --git a/libpwdgrp/__getgrent.c b/libpwdgrp/__getgrent.c
index 39cf189..5fb4193 100644
--- a/libpwdgrp/__getgrent.c
+++ b/libpwdgrp/__getgrent.c
@@ -186,8 +186,7 @@ struct group *__getgrent(int grp_fd)
members[member_num + 1] = NULL;
}
#else /* !GR_SCALE_DYNAMIC */
- if (members != NULL)
- free(members);
+ free(members);
members = (char **) malloc((member_num + 1) * sizeof(char *));
for ( ; field_begin && *field_begin != '\0'; field_begin = ptr) {
if ((ptr = strchr(field_begin, ',')) != NULL)
diff --git a/modutils/insmod.c b/modutils/insmod.c
index b367e84..eda4e1a 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -234,7 +234,7 @@
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
-#ident "$Id: insmod.c,v 1.91 2002/10/10 04:20:21 andersen Exp $"
+#ident "$Id: insmod.c,v 1.92 2002/11/28 11:27:27 aaronl Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
@@ -455,7 +455,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
-#ident "$Id: insmod.c,v 1.91 2002/10/10 04:20:21 andersen Exp $"
+#ident "$Id: insmod.c,v 1.92 2002/11/28 11:27:27 aaronl Exp $"
/* The relocatable object is manipulated using elfin types. */
@@ -3589,8 +3589,7 @@ extern int insmod_main( int argc, char **argv)
flag_export = 0;
break;
case 'o': /* name the output module */
- if(m_name) /* Hmmm, duplicate "-o name". */
- free(m_name);
+ free(m_name);
m_name = xstrdup(optarg);
break;
case 'L': /* Stub warning */
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 295486c..b50b1ed 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
switch (c) {
case 'c':
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
- if (client_config.clientid) free(client_config.clientid);
+ free(client_config.clientid);
client_config.clientid = xmalloc(len + 2);
client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
client_config.clientid[OPT_LEN] = len;
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
case 'h':
case 'H':
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
- if (client_config.hostname) free(client_config.hostname);
+ free(client_config.hostname);
client_config.hostname = xmalloc(len + 2);
client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
client_config.hostname[OPT_LEN] = len;
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 842e0f2..cf72de1 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -38,7 +38,7 @@ static int read_str(char *line, void *arg)
{
char **dest = arg;
- if (*dest) free(*dest);
+ free(*dest);
*dest = strdup(line);
return 1;
diff --git a/shell/hush.c b/shell/hush.c
index 08b3b29..48d1d14 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -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;
diff --git a/shell/lash.c b/shell/lash.c
index 7994d26..c4d6ef0 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -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;
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index dbe4f74..d332b6b 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -1314,9 +1314,7 @@ static void free_name_list(void)
if (name_list) {
for (i = 0; i < MAX_DEPTH; i++) {
- if (name_list[i]) {
- free(name_list[i]);
- }
+ free(name_list[i]);
}
free(name_list);
}
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 2390f30..e126d7b 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -92,8 +92,7 @@ const char *normalize(const char *arg)
const char *argptr=arg;
char *bufptr;
- if (BUFFER != NULL)
- free(BUFFER);
+ free(BUFFER);
if (!quote) { /* Just copy arg */
BUFFER=xstrdup(arg);
@@ -340,16 +339,14 @@ int getopt_main(int argc, char *argv[])
alternative=1;
break;
case 'o':
- if (optstr)
- free(optstr);
+ free(optstr);
optstr=xstrdup(optarg);
break;
case 'l':
add_long_options(optarg);
break;
case 'n':
- if (name)
- free(name);
+ free(name);
name=xstrdup(optarg);
break;
case 'q':
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 29e2e3b..391d245 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -158,10 +158,8 @@ static void mtab_free(void)
this = mtab_cache;
while (this) {
next = this->next;
- if (this->device)
- free(this->device);
- if (this->mountpt)
- free(this->mountpt);
+ free(this->device);
+ free(this->mountpt);
free(this);
this = next;
}