diff options
author | Aaron Lehmann <aaronl@vitelius.com> | 2002-11-28 11:27:31 +0000 |
---|---|---|
committer | Aaron Lehmann <aaronl@vitelius.com> | 2002-11-28 11:27:31 +0000 |
commit | a170e1c858d35c474ceb9fecb41b37d681424094 (patch) | |
tree | cda2b13f10ca1ab0a3559d4b6ff663ed20d7106c /editors/vi.c | |
parent | 1652855fbc830f41c7ee56ece1a30b328c4fb395 (diff) | |
download | busybox-w32-a170e1c858d35c474ceb9fecb41b37d681424094.tar.gz busybox-w32-a170e1c858d35c474ceb9fecb41b37d681424094.tar.bz2 busybox-w32-a170e1c858d35c474ceb9fecb41b37d681424094.zip |
Change if(x)free(x); to free(x);
Diffstat (limited to 'editors/vi.c')
-rw-r--r-- | editors/vi.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/editors/vi.c b/editors/vi.c index 1275d133b..835adb62e 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | static const char vi_Version[] = | 21 | static const char vi_Version[] = |
22 | "$Id: vi.c,v 1.24 2002/10/26 10:19:19 andersen Exp $"; | 22 | "$Id: vi.c,v 1.25 2002/11/28 11:27:23 aaronl Exp $"; |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * To compile for standalone use: | 25 | * To compile for standalone use: |
@@ -383,8 +383,7 @@ extern int vi_main(int argc, char **argv) | |||
383 | } else { | 383 | } else { |
384 | for (; optind < argc; optind++) { | 384 | for (; optind < argc; optind++) { |
385 | editing = 1; // 0=exit, 1=one file, 2+ =many files | 385 | editing = 1; // 0=exit, 1=one file, 2+ =many files |
386 | if (cfn != 0) | 386 | free(cfn); |
387 | free(cfn); | ||
388 | cfn = (Byte *) xstrdup(argv[optind]); | 387 | cfn = (Byte *) xstrdup(argv[optind]); |
389 | edit_file(cfn); | 388 | edit_file(cfn); |
390 | } | 389 | } |
@@ -490,10 +489,8 @@ static void edit_file(Byte * fn) | |||
490 | offset = 0; // no horizontal offset | 489 | offset = 0; // no horizontal offset |
491 | c = '\0'; | 490 | c = '\0'; |
492 | #ifdef CONFIG_FEATURE_VI_DOT_CMD | 491 | #ifdef CONFIG_FEATURE_VI_DOT_CMD |
493 | if (last_modifying_cmd != 0) | 492 | free(last_modifying_cmd); |
494 | free(last_modifying_cmd); | 493 | free(ioq_start); |
495 | if (ioq_start != NULL) | ||
496 | free(ioq_start); | ||
497 | ioq = ioq_start = last_modifying_cmd = 0; | 494 | ioq = ioq_start = last_modifying_cmd = 0; |
498 | adding2q = 0; | 495 | adding2q = 0; |
499 | #endif /* CONFIG_FEATURE_VI_DOT_CMD */ | 496 | #endif /* CONFIG_FEATURE_VI_DOT_CMD */ |
@@ -998,8 +995,7 @@ static void colon(Byte * buf) | |||
998 | // There is a read-able regular file | 995 | // There is a read-able regular file |
999 | // make this the current file | 996 | // make this the current file |
1000 | q = (Byte *) xstrdup((char *) fn); // save the cfn | 997 | q = (Byte *) xstrdup((char *) fn); // save the cfn |
1001 | if (cfn != 0) | 998 | free(cfn); // free the old name |
1002 | free(cfn); // free the old name | ||
1003 | cfn = q; // remember new cfn | 999 | cfn = q; // remember new cfn |
1004 | 1000 | ||
1005 | vc5: | 1001 | vc5: |
@@ -1048,8 +1044,7 @@ static void colon(Byte * buf) | |||
1048 | } | 1044 | } |
1049 | if (strlen((char *) args) > 0) { | 1045 | if (strlen((char *) args) > 0) { |
1050 | // user wants a new filename | 1046 | // user wants a new filename |
1051 | if (cfn != NULL) | 1047 | free(cfn); |
1052 | free(cfn); | ||
1053 | cfn = (Byte *) xstrdup((char *) args); | 1048 | cfn = (Byte *) xstrdup((char *) args); |
1054 | } else { | 1049 | } else { |
1055 | // user wants file status info | 1050 | // user wants file status info |
@@ -1635,8 +1630,7 @@ static Byte *new_screen(int ro, int co) | |||
1635 | { | 1630 | { |
1636 | int li; | 1631 | int li; |
1637 | 1632 | ||
1638 | if (screen != 0) | 1633 | free(screen); |
1639 | free(screen); | ||
1640 | screensize = ro * co + 8; | 1634 | screensize = ro * co + 8; |
1641 | screen = (Byte *) xmalloc(screensize); | 1635 | screen = (Byte *) xmalloc(screensize); |
1642 | // initialize the new screen. assume this will be a empty file. | 1636 | // initialize the new screen. assume this will be a empty file. |
@@ -1652,10 +1646,7 @@ static Byte *new_text(int size) | |||
1652 | { | 1646 | { |
1653 | if (size < 10240) | 1647 | if (size < 10240) |
1654 | size = 10240; // have a minimum size for new files | 1648 | size = 10240; // have a minimum size for new files |
1655 | if (text != 0) { | 1649 | free(text); |
1656 | //text -= 4; | ||
1657 | free(text); | ||
1658 | } | ||
1659 | text = (Byte *) xmalloc(size + 8); | 1650 | text = (Byte *) xmalloc(size + 8); |
1660 | memset(text, '\0', size); // clear new text[] | 1651 | memset(text, '\0', size); // clear new text[] |
1661 | //text += 4; // leave some room for "oops" | 1652 | //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 | |||
2171 | static void start_new_cmd_q(Byte c) | 2162 | static void start_new_cmd_q(Byte c) |
2172 | { | 2163 | { |
2173 | // release old cmd | 2164 | // release old cmd |
2174 | if (last_modifying_cmd != 0) | 2165 | free(last_modifying_cmd); |
2175 | free(last_modifying_cmd); | ||
2176 | // get buffer for new cmd | 2166 | // get buffer for new cmd |
2177 | last_modifying_cmd = (Byte *) xmalloc(BUFSIZ); | 2167 | last_modifying_cmd = (Byte *) xmalloc(BUFSIZ); |
2178 | memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue | 2168 | 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 | |||
2227 | } | 2217 | } |
2228 | cnt = q - p + 1; | 2218 | cnt = q - p + 1; |
2229 | t = reg[dest]; | 2219 | t = reg[dest]; |
2230 | if (t != 0) { // if already a yank register | 2220 | free(t); // if already a yank register, free it |
2231 | free(t); // free it | ||
2232 | } | ||
2233 | t = (Byte *) xmalloc(cnt + 1); // get a new register | 2221 | t = (Byte *) xmalloc(cnt + 1); // get a new register |
2234 | memset(t, '\0', cnt + 1); // clear new text[] | 2222 | memset(t, '\0', cnt + 1); // clear new text[] |
2235 | strncpy((char *) t, (char *) p, cnt); // copy text[] into bufer | 2223 | 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" | |||
2615 | } | 2603 | } |
2616 | } | 2604 | } |
2617 | refresh(FALSE); | 2605 | refresh(FALSE); |
2618 | if (obufp != NULL) | 2606 | free(obufp); |
2619 | free(obufp); | ||
2620 | obufp = (Byte *) xstrdup((char *) buf); | 2607 | obufp = (Byte *) xstrdup((char *) buf); |
2621 | return (obufp); | 2608 | return (obufp); |
2622 | } | 2609 | } |
@@ -3454,9 +3441,7 @@ key_cmd_mode: | |||
3454 | goto dc3; // if no pat re-use old pat | 3441 | goto dc3; // if no pat re-use old pat |
3455 | if (strlen((char *) q) > 1) { // new pat- save it and find | 3442 | if (strlen((char *) q) > 1) { // new pat- save it and find |
3456 | // there is a new pat | 3443 | // there is a new pat |
3457 | if (last_search_pattern != 0) { | 3444 | free(last_search_pattern); |
3458 | free(last_search_pattern); | ||
3459 | } | ||
3460 | last_search_pattern = (Byte *) xstrdup((char *) q); | 3445 | last_search_pattern = (Byte *) xstrdup((char *) q); |
3461 | goto dc3; // now find the pattern | 3446 | goto dc3; // now find the pattern |
3462 | } | 3447 | } |