diff options
author | Jim Meyering <jim@meyering.net> | 2004-01-04 21:12:00 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2004-01-04 21:12:00 +0000 |
commit | a6c6e57b713ea727af66cac361fe43ec1eab916a (patch) | |
tree | 1c0583b437bc18f3d663b90a7c31082943635572 /src | |
parent | cc52b7fc4351b041b8f7cd7a65a0ff6c603cfecb (diff) | |
download | coreutils-a6c6e57b713ea727af66cac361fe43ec1eab916a.tar.xz |
(add_temp_dir): Use x2nrealloc rather than xrealloc.
(fillbuf): Use x2nrealloc rather than xrealloc.
(sort): Use xnmalloc rather than xmalloc.
(main): Likewise.
Diffstat (limited to 'src')
-rw-r--r-- | src/sort.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/sort.c b/src/sort.c index 459dba998..547d7893a 100644 --- a/src/sort.c +++ b/src/sort.c @@ -498,10 +498,7 @@ static void add_temp_dir (char const *dir) { if (temp_dir_count == temp_dir_alloc) - { - temp_dir_alloc = temp_dir_alloc ? temp_dir_alloc * 2 : 16; - temp_dirs = xrealloc (temp_dirs, sizeof (temp_dirs) * temp_dir_alloc); - } + temp_dirs = x2nrealloc (temp_dirs, &temp_dir_alloc, sizeof *temp_dirs); temp_dirs[temp_dir_count++] = dir; } @@ -1053,10 +1050,7 @@ fillbuf (struct buffer *buf, register FILE *fp, char const *file) /* The current input line is too long to fit in the buffer. Double the buffer size and try again. */ - if (2 * buf->alloc < buf->alloc) - xalloc_die (); - buf->alloc *= 2; - buf->buf = xrealloc (buf->buf, buf->alloc); + buf->buf = x2nrealloc (buf->buf, &buf->alloc, sizeof *(buf->buf)); } } @@ -2060,7 +2054,7 @@ sort (char * const *files, int nfiles, char const *output_file) { int i = n_temp_files; struct tempnode *node; - char **tempfiles = xmalloc (n_temp_files * sizeof (char *)); + char **tempfiles = xnmalloc (n_temp_files, sizeof *tempfiles); for (node = temphead; i > 0; node = node->next) tempfiles[--i] = node->name; merge (tempfiles, n_temp_files, NMERGE, output_file); @@ -2313,7 +2307,7 @@ main (int argc, char **argv) gkey.numeric = gkey.general_numeric = gkey.month = gkey.reverse = false; gkey.skipsblanks = gkey.skipeblanks = false; - files = xmalloc (sizeof (char *) * argc); + files = xnmalloc (argc, sizeof *files); for (;;) { |