diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-11-17 06:57:42 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-11-17 06:57:42 +0000 |
commit | 80f5ac7016e966c87333c9a776989600313e7e4e (patch) | |
tree | 1de0249bd21af30eacaa1fba0f53a57ff0a9bdd1 /editors/vi.c | |
parent | 26f8e95d2d6efe4c25a80314fc2a4333099c0eaa (diff) | |
download | busybox-w32-80f5ac7016e966c87333c9a776989600313e7e4e.tar.gz busybox-w32-80f5ac7016e966c87333c9a776989600313e7e4e.tar.bz2 busybox-w32-80f5ac7016e966c87333c9a776989600313e7e4e.zip |
Patch from Steve Merrifield <steve@labyrinth.net.au> to make vi
use xmalloc
Diffstat (limited to 'editors/vi.c')
-rw-r--r-- | editors/vi.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/editors/vi.c b/editors/vi.c index b65c9cf42..b1c957def 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.17 2001/11/12 16:57:26 kraai Exp $"; | 22 | "$Id: vi.c,v 1.18 2001/11/17 06:57:42 andersen Exp $"; |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * To compile for standalone use: | 25 | * To compile for standalone use: |
@@ -324,7 +324,7 @@ extern int vi_main(int argc, char **argv) | |||
324 | #ifdef CONFIG_FEATURE_VI_CRASHME | 324 | #ifdef CONFIG_FEATURE_VI_CRASHME |
325 | (void) srand((long) getpid()); | 325 | (void) srand((long) getpid()); |
326 | #endif /* CONFIG_FEATURE_VI_CRASHME */ | 326 | #endif /* CONFIG_FEATURE_VI_CRASHME */ |
327 | status_buffer = (Byte *) malloc(200); // hold messages to user | 327 | status_buffer = (Byte *) xmalloc(200); // hold messages to user |
328 | #ifdef CONFIG_FEATURE_VI_READONLY | 328 | #ifdef CONFIG_FEATURE_VI_READONLY |
329 | vi_readonly = readonly = FALSE; | 329 | vi_readonly = readonly = FALSE; |
330 | if (strncmp(argv[0], "view", 4) == 0) { | 330 | if (strncmp(argv[0], "view", 4) == 0) { |
@@ -2492,7 +2492,7 @@ static Byte *new_screen(int ro, int co) | |||
2492 | if (screen != 0) | 2492 | if (screen != 0) |
2493 | free(screen); | 2493 | free(screen); |
2494 | screensize = ro * co + 8; | 2494 | screensize = ro * co + 8; |
2495 | screen = (Byte *) malloc(screensize); | 2495 | screen = (Byte *) xmalloc(screensize); |
2496 | // initialize the new screen. assume this will be a empty file. | 2496 | // initialize the new screen. assume this will be a empty file. |
2497 | screen_erase(); | 2497 | screen_erase(); |
2498 | // non-existant text[] lines start with a tilde (~). | 2498 | // non-existant text[] lines start with a tilde (~). |
@@ -2510,7 +2510,7 @@ static Byte *new_text(int size) | |||
2510 | //text -= 4; | 2510 | //text -= 4; |
2511 | free(text); | 2511 | free(text); |
2512 | } | 2512 | } |
2513 | text = (Byte *) malloc(size + 8); | 2513 | text = (Byte *) xmalloc(size + 8); |
2514 | memset(text, '\0', size); // clear new text[] | 2514 | memset(text, '\0', size); // clear new text[] |
2515 | //text += 4; // leave some room for "oops" | 2515 | //text += 4; // leave some room for "oops" |
2516 | textend = text + size - 1; | 2516 | textend = text + size - 1; |
@@ -3028,7 +3028,7 @@ static void start_new_cmd_q(Byte c) | |||
3028 | if (last_modifying_cmd != 0) | 3028 | if (last_modifying_cmd != 0) |
3029 | free(last_modifying_cmd); | 3029 | free(last_modifying_cmd); |
3030 | // get buffer for new cmd | 3030 | // get buffer for new cmd |
3031 | last_modifying_cmd = (Byte *) malloc(BUFSIZ); | 3031 | last_modifying_cmd = (Byte *) xmalloc(BUFSIZ); |
3032 | memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue | 3032 | memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue |
3033 | // if there is a current cmd count put it in the buffer first | 3033 | // if there is a current cmd count put it in the buffer first |
3034 | if (cmdcnt > 0) | 3034 | if (cmdcnt > 0) |
@@ -3084,7 +3084,7 @@ static Byte *text_yank(Byte * p, Byte * q, int dest) // copy text into a registe | |||
3084 | if (t != 0) { // if already a yank register | 3084 | if (t != 0) { // if already a yank register |
3085 | free(t); // free it | 3085 | free(t); // free it |
3086 | } | 3086 | } |
3087 | t = (Byte *) malloc(cnt + 1); // get a new register | 3087 | t = (Byte *) xmalloc(cnt + 1); // get a new register |
3088 | memset(t, '\0', cnt + 1); // clear new text[] | 3088 | memset(t, '\0', cnt + 1); // clear new text[] |
3089 | strncpy((char *) t, (char *) p, cnt); // copy text[] into bufer | 3089 | strncpy((char *) t, (char *) p, cnt); // copy text[] into bufer |
3090 | reg[dest] = t; | 3090 | reg[dest] = t; |