diff options
author | Jim Meyering <jim@meyering.net> | 2004-01-04 21:10:11 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2004-01-04 21:10:11 +0000 |
commit | cc52b7fc4351b041b8f7cd7a65a0ff6c603cfecb (patch) | |
tree | 3c568be545e7a45da489104b3a321debcbea50ad /src/expand.c | |
parent | 5ad984ecc0546129cdd29eeb4808c5d8733a6935 (diff) | |
download | coreutils-cc52b7fc4351b041b8f7cd7a65a0ff6c603cfecb.tar.gz coreutils-cc52b7fc4351b041b8f7cd7a65a0ff6c603cfecb.tar.bz2 coreutils-cc52b7fc4351b041b8f7cd7a65a0ff6c603cfecb.zip |
(n_tabs_allocated): New global.
(add_tabstop): Use x2nrealloc rather than xrealloc.
Diffstat (limited to 'src/expand.c')
-rw-r--r-- | src/expand.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/expand.c b/src/expand.c index 8be52b563..f92dca32a 100644 --- a/src/expand.c +++ b/src/expand.c @@ -53,10 +53,6 @@ allocated for the output line. */ #define OUTPUT_BLOCK 256 -/* The number of bytes added at a time to the amount of memory - allocated for the list of tabstops. */ -#define TABLIST_BLOCK 256 - /* The name this program was run with. */ char *program_name; @@ -74,7 +70,8 @@ static int *tab_list; /* The index of the first invalid element of `tab_list', where the next element can be added. */ -static int first_free_tab; +static size_t first_free_tab; +static size_t n_tabs_allocated; /* Null-terminated array of input filenames. */ static char **file_list; @@ -142,9 +139,8 @@ add_tabstop (int tabval) { if (tabval == -1) return; - if (first_free_tab % TABLIST_BLOCK == 0) - tab_list = xrealloc (tab_list, (first_free_tab - + TABLIST_BLOCK * sizeof (tab_list[0]))); + if (first_free_tab == n_tabs_allocated) + tab_list = x2nrealloc (tab_list, &n_tabs_allocated, sizeof *tab_list); tab_list[first_free_tab++] = tabval; } |