diff options
author | Matt Kraai <kraai@debian.org> | 2000-09-13 06:46:14 +0400 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-09-13 06:46:14 +0400 |
commit | 322ae93a5e0b78b65831f9fd87fd456eb84d21a1 (patch) | |
tree | 5b967e1d873ff6eff8296bf9fda73825f0c55884 /coreutils/sort.c | |
parent | b89075298edf0a471b9046b1f3c8a936e18ead20 (diff) |
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 'coreutils/sort.c')
-rw-r--r-- | coreutils/sort.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c index 6af5c4df3..a74f96ad0 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c @@ -64,7 +64,7 @@ static const int max = 1024; static Line *line_alloc() { Line *self; - self = malloc(1 * sizeof(Line)); + self = xmalloc(1 * sizeof(Line)); return self; } @@ -76,9 +76,6 @@ static Line *line_newFromFile(FILE * src) if ((cstring = get_line_from_file(src))) { self = line_alloc(); - if (self == NULL) { - return NULL; - } self->data = cstring; self->next = NULL; return self; @@ -173,10 +170,7 @@ static List *list_sort(List * self, Compare * compare) Line *line; /* mallocate array of Line*s */ - self->sorted = (Line **) malloc(self->len * sizeof(Line *)); - if (self->sorted == NULL) { - return NULL; - } + self->sorted = (Line **) xmalloc(self->len * sizeof(Line *)); /* fill array w/ List's contents */ i = 0; @@ -294,4 +288,4 @@ int sort_main(int argc, char **argv) return(0); } -/* $Id: sort.c,v 1.20 2000/07/16 20:57:15 kraai Exp $ */ +/* $Id: sort.c,v 1.21 2000/09/13 02:46:13 kraai Exp $ */ |