diff options
author | Matt Kraai <kraai@debian.org> | 2000-09-13 02:46:14 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-09-13 02:46:14 +0000 |
commit | 322ae93a5e0b78b65831f9fd87fd456eb84d21a1 (patch) | |
tree | 5b967e1d873ff6eff8296bf9fda73825f0c55884 /shell | |
parent | b89075298edf0a471b9046b1f3c8a936e18ead20 (diff) | |
download | busybox-w32-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.tar.gz busybox-w32-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.tar.bz2 busybox-w32-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.zip |
Fix calls to {m,c,re}alloc so that they use x{m,c,re}alloc instead of
segfaulting or handling errors the same way themselves.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/cmdedit.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 042064f1e..04abc938c 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -246,11 +246,11 @@ char** username_tab_completion(char* command, int *num_matches) | |||
246 | char** exe_n_cwd_tab_completion(char* command, int *num_matches) | 246 | char** exe_n_cwd_tab_completion(char* command, int *num_matches) |
247 | { | 247 | { |
248 | char *dirName; | 248 | char *dirName; |
249 | char **matches = (char **) NULL; | 249 | char **matches; |
250 | DIR *dir; | 250 | DIR *dir; |
251 | struct dirent *next; | 251 | struct dirent *next; |
252 | 252 | ||
253 | matches = malloc( sizeof(char*)*50); | 253 | matches = xmalloc( sizeof(char*)*50); |
254 | 254 | ||
255 | /* Stick a wildcard onto the command, for later use */ | 255 | /* Stick a wildcard onto the command, for later use */ |
256 | strcat( command, "*"); | 256 | strcat( command, "*"); |
@@ -273,7 +273,7 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches) | |||
273 | /* See if this matches */ | 273 | /* See if this matches */ |
274 | if (check_wildcard_match(next->d_name, command) == TRUE) { | 274 | if (check_wildcard_match(next->d_name, command) == TRUE) { |
275 | /* Cool, found a match. Add it to the list */ | 275 | /* Cool, found a match. Add it to the list */ |
276 | matches[*num_matches] = malloc(strlen(next->d_name)+1); | 276 | matches[*num_matches] = xmalloc(strlen(next->d_name)+1); |
277 | strcpy( matches[*num_matches], next->d_name); | 277 | strcpy( matches[*num_matches], next->d_name); |
278 | ++*num_matches; | 278 | ++*num_matches; |
279 | //matches = realloc( matches, sizeof(char*)*(*num_matches)); | 279 | //matches = realloc( matches, sizeof(char*)*(*num_matches)); |
@@ -302,7 +302,7 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len) | |||
302 | 302 | ||
303 | /* Make a local copy of the string -- up | 303 | /* Make a local copy of the string -- up |
304 | * to the position of the cursor */ | 304 | * to the position of the cursor */ |
305 | matchBuf = (char *) calloc(BUFSIZ, sizeof(char)); | 305 | matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char)); |
306 | strncpy(matchBuf, command, cursor); | 306 | strncpy(matchBuf, command, cursor); |
307 | tmp=matchBuf; | 307 | tmp=matchBuf; |
308 | 308 | ||
@@ -670,8 +670,8 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
670 | 670 | ||
671 | if (!h) { | 671 | if (!h) { |
672 | /* No previous history -- this memory is never freed */ | 672 | /* No previous history -- this memory is never freed */ |
673 | h = his_front = malloc(sizeof(struct history)); | 673 | h = his_front = xmalloc(sizeof(struct history)); |
674 | h->n = malloc(sizeof(struct history)); | 674 | h->n = xmalloc(sizeof(struct history)); |
675 | 675 | ||
676 | h->p = NULL; | 676 | h->p = NULL; |
677 | h->s = strdup(command); | 677 | h->s = strdup(command); |
@@ -682,7 +682,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
682 | history_counter++; | 682 | history_counter++; |
683 | } else { | 683 | } else { |
684 | /* Add a new history command -- this memory is never freed */ | 684 | /* Add a new history command -- this memory is never freed */ |
685 | h->n = malloc(sizeof(struct history)); | 685 | h->n = xmalloc(sizeof(struct history)); |
686 | 686 | ||
687 | h->n->p = h; | 687 | h->n->p = h; |
688 | h->n->n = NULL; | 688 | h->n->n = NULL; |