summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorAaron Lehmann2002-11-28 11:27:31 +0000
committerAaron Lehmann2002-11-28 11:27:31 +0000
commita170e1c858d35c474ceb9fecb41b37d681424094 (patch)
treecda2b13f10ca1ab0a3559d4b6ff663ed20d7106c /editors
parent1652855fbc830f41c7ee56ece1a30b328c4fb395 (diff)
downloadbusybox-a170e1c858d35c474ceb9fecb41b37d681424094.zip
busybox-a170e1c858d35c474ceb9fecb41b37d681424094.tar.gz
Change if(x)free(x); to free(x);
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c9
-rw-r--r--editors/sed.c3
-rw-r--r--editors/vi.c39
3 files changed, 17 insertions, 34 deletions
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
}