aboutsummaryrefslogtreecommitdiff
path: root/coreutils/sort.c
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-09-13 02:46:14 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-09-13 02:46:14 +0000
commit9f559aa7068b38ba510640873a58953e94139248 (patch)
tree5b967e1d873ff6eff8296bf9fda73825f0c55884 /coreutils/sort.c
parent033cbe20a6a0389007a333a4fdf1dc87d8eb368e (diff)
downloadbusybox-w32-9f559aa7068b38ba510640873a58953e94139248.tar.gz
busybox-w32-9f559aa7068b38ba510640873a58953e94139248.tar.bz2
busybox-w32-9f559aa7068b38ba510640873a58953e94139248.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. git-svn-id: svn://busybox.net/trunk/busybox@1039 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils/sort.c')
-rw-r--r--coreutils/sort.c12
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;
64static Line *line_alloc() 64static Line *line_alloc()
65{ 65{
66 Line *self; 66 Line *self;
67 self = malloc(1 * sizeof(Line)); 67 self = xmalloc(1 * sizeof(Line));
68 return self; 68 return self;
69} 69}
70 70
@@ -76,9 +76,6 @@ static Line *line_newFromFile(FILE * src)
76 76
77 if ((cstring = get_line_from_file(src))) { 77 if ((cstring = get_line_from_file(src))) {
78 self = line_alloc(); 78 self = line_alloc();
79 if (self == NULL) {
80 return NULL;
81 }
82 self->data = cstring; 79 self->data = cstring;
83 self->next = NULL; 80 self->next = NULL;
84 return self; 81 return self;
@@ -173,10 +170,7 @@ static List *list_sort(List * self, Compare * compare)
173 Line *line; 170 Line *line;
174 171
175 /* mallocate array of Line*s */ 172 /* mallocate array of Line*s */
176 self->sorted = (Line **) malloc(self->len * sizeof(Line *)); 173 self->sorted = (Line **) xmalloc(self->len * sizeof(Line *));
177 if (self->sorted == NULL) {
178 return NULL;
179 }
180 174
181 /* fill array w/ List's contents */ 175 /* fill array w/ List's contents */
182 i = 0; 176 i = 0;
@@ -294,4 +288,4 @@ int sort_main(int argc, char **argv)
294 return(0); 288 return(0);
295} 289}
296 290
297/* $Id: sort.c,v 1.20 2000/07/16 20:57:15 kraai Exp $ */ 291/* $Id: sort.c,v 1.21 2000/09/13 02:46:13 kraai Exp $ */