diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/awk.c | 9 | ||||
-rw-r--r-- | editors/sed.c | 3 | ||||
-rw-r--r-- | editors/vi.c | 39 |
3 files changed, 17 insertions, 34 deletions
diff --git a/editors/awk.c b/editors/awk.c index aea852b0d..44c2f45b2 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -650,7 +650,7 @@ static void clear_array(xhash *array) { | |||
650 | while (hi) { | 650 | while (hi) { |
651 | thi = hi; | 651 | thi = hi; |
652 | hi = hi->next; | 652 | hi = hi->next; |
653 | if (thi->data.v.string) free(thi->data.v.string); | 653 | free(thi->data.v.string); |
654 | free(thi); | 654 | free(thi); |
655 | } | 655 | } |
656 | array->items[i] = NULL; | 656 | array->items[i] = NULL; |
@@ -661,7 +661,7 @@ static void clear_array(xhash *array) { | |||
661 | /* clear a variable */ | 661 | /* clear a variable */ |
662 | static var *clrvar(var *v) { | 662 | static var *clrvar(var *v) { |
663 | 663 | ||
664 | if (v->string && !(v->type & VF_FSTR)) | 664 | if (!(v->type & VF_FSTR)) |
665 | free(v->string); | 665 | free(v->string); |
666 | 666 | ||
667 | v->type &= VF_DONTTOUCH; | 667 | v->type &= VF_DONTTOUCH; |
@@ -1504,7 +1504,7 @@ static void split_f0(void) { | |||
1504 | return; | 1504 | return; |
1505 | 1505 | ||
1506 | is_f0_split = TRUE; | 1506 | is_f0_split = TRUE; |
1507 | if (fstrings) free(fstrings); | 1507 | free(fstrings); |
1508 | fsrealloc(0); | 1508 | fsrealloc(0); |
1509 | n = awk_split(getvar_s(V[F0]), &fsplitter.n, &fstrings); | 1509 | n = awk_split(getvar_s(V[F0]), &fsplitter.n, &fstrings); |
1510 | fsrealloc(n); | 1510 | fsrealloc(n); |
@@ -2376,8 +2376,7 @@ re_cont: | |||
2376 | X.rsm = (rstream *)hash_search(fdhash, L.s); | 2376 | X.rsm = (rstream *)hash_search(fdhash, L.s); |
2377 | if (X.rsm) { | 2377 | if (X.rsm) { |
2378 | R.i = X.rsm->is_pipe ? pclose(X.rsm->F) : fclose(X.rsm->F); | 2378 | R.i = X.rsm->is_pipe ? pclose(X.rsm->F) : fclose(X.rsm->F); |
2379 | if (X.rsm->buffer) | 2379 | free(X.rsm->buffer); |
2380 | free(X.rsm->buffer); | ||
2381 | hash_remove(fdhash, L.s); | 2380 | hash_remove(fdhash, L.s); |
2382 | } | 2381 | } |
2383 | if (R.i != 0) | 2382 | if (R.i != 0) |
diff --git a/editors/sed.c b/editors/sed.c index 23e9d545b..df623465f 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -130,8 +130,7 @@ static void destroy_cmd_strs(void) | |||
130 | regfree(sed_cmds[ncmds].sub_match); | 130 | regfree(sed_cmds[ncmds].sub_match); |
131 | free(sed_cmds[ncmds].sub_match); | 131 | free(sed_cmds[ncmds].sub_match); |
132 | } | 132 | } |
133 | if (sed_cmds[ncmds].replace) | 133 | free(sed_cmds[ncmds].replace); |
134 | free(sed_cmds[ncmds].replace); | ||
135 | } | 134 | } |
136 | 135 | ||
137 | /* destroy the array */ | 136 | /* destroy the array */ |
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 | } |