diff options
author | Matt Kraai | 2000-09-13 02:46:14 +0000 |
---|---|---|
committer | Matt Kraai | 2000-09-13 02:46:14 +0000 |
commit | 322ae93a5e0b78b65831f9fd87fd456eb84d21a1 (patch) | |
tree | 5b967e1d873ff6eff8296bf9fda73825f0c55884 /shell | |
parent | b89075298edf0a471b9046b1f3c8a936e18ead20 (diff) | |
download | busybox-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.zip busybox-322ae93a5e0b78b65831f9fd87fd456eb84d21a1.tar.gz |
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 042064f..04abc93 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c @@ -246,11 +246,11 @@ char** username_tab_completion(char* command, int *num_matches) char** exe_n_cwd_tab_completion(char* command, int *num_matches) { char *dirName; - char **matches = (char **) NULL; + char **matches; DIR *dir; struct dirent *next; - matches = malloc( sizeof(char*)*50); + matches = xmalloc( sizeof(char*)*50); /* Stick a wildcard onto the command, for later use */ strcat( command, "*"); @@ -273,7 +273,7 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches) /* See if this matches */ if (check_wildcard_match(next->d_name, command) == TRUE) { /* Cool, found a match. Add it to the list */ - matches[*num_matches] = malloc(strlen(next->d_name)+1); + matches[*num_matches] = xmalloc(strlen(next->d_name)+1); strcpy( matches[*num_matches], next->d_name); ++*num_matches; //matches = realloc( matches, sizeof(char*)*(*num_matches)); @@ -302,7 +302,7 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len) /* Make a local copy of the string -- up * to the position of the cursor */ - matchBuf = (char *) calloc(BUFSIZ, sizeof(char)); + matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char)); strncpy(matchBuf, command, cursor); tmp=matchBuf; @@ -670,8 +670,8 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) if (!h) { /* No previous history -- this memory is never freed */ - h = his_front = malloc(sizeof(struct history)); - h->n = malloc(sizeof(struct history)); + h = his_front = xmalloc(sizeof(struct history)); + h->n = xmalloc(sizeof(struct history)); h->p = NULL; h->s = strdup(command); @@ -682,7 +682,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) history_counter++; } else { /* Add a new history command -- this memory is never freed */ - h->n = malloc(sizeof(struct history)); + h->n = xmalloc(sizeof(struct history)); h->n->p = h; h->n->n = NULL; |