[BusyBox] [PATCH] - updates malloc to xmalloc in vi.c
Steve Merrifield
steve at labyrinth.net.au
Tue Nov 13 02:07:20 UTC 2001
Here is a patch for vi that updates malloc to xmalloc. I think this
patch
now brings all applets into line in regards to using xmalloc, xcalloc,
xrealloc
and xstrdup calls rather than the standard library calls.
steve
-------------- next part --------------
--- vi-orig.c Tue Nov 13 20:05:43 2001
+++ vi.c Tue Nov 13 20:06:56 2001
@@ -324,7 +324,7 @@
#ifdef CONFIG_FEATURE_VI_CRASHME
(void) srand((long) getpid());
#endif /* CONFIG_FEATURE_VI_CRASHME */
- status_buffer = (Byte *) malloc(200); // hold messages to user
+ status_buffer = (Byte *) xmalloc(200); // hold messages to user
#ifdef CONFIG_FEATURE_VI_READONLY
vi_readonly = readonly = FALSE;
if (strncmp(argv[0], "view", 4) == 0) {
@@ -2492,7 +2492,7 @@
if (screen != 0)
free(screen);
screensize = ro * co + 8;
- screen = (Byte *) malloc(screensize);
+ screen = (Byte *) xmalloc(screensize);
// initialize the new screen. assume this will be a empty file.
screen_erase();
// non-existant text[] lines start with a tilde (~).
@@ -2510,7 +2510,7 @@
//text -= 4;
free(text);
}
- text = (Byte *) malloc(size + 8);
+ text = (Byte *) xmalloc(size + 8);
memset(text, '\0', size); // clear new text[]
//text += 4; // leave some room for "oops"
textend = text + size - 1;
@@ -3028,7 +3028,7 @@
if (last_modifying_cmd != 0)
free(last_modifying_cmd);
// get buffer for new cmd
- last_modifying_cmd = (Byte *) malloc(BUFSIZ);
+ last_modifying_cmd = (Byte *) xmalloc(BUFSIZ);
memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue
// if there is a current cmd count put it in the buffer first
if (cmdcnt > 0)
@@ -3084,7 +3084,7 @@
if (t != 0) { // if already a yank register
free(t); // free it
}
- t = (Byte *) malloc(cnt + 1); // get a new register
+ 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
reg[dest] = t;
More information about the busybox
mailing list