]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(n_tabs_allocated): New global.
authorJim Meyering <jim@meyering.net>
Sun, 4 Jan 2004 21:09:30 +0000 (21:09 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 4 Jan 2004 21:09:30 +0000 (21:09 +0000)
(add_tabstop): Use x2nrealloc rather than xrealloc.

src/unexpand.c

index ac50629e6dfd1fab193d6b0c4442a9f72eec163a..c65c210a932f3b132fbd7b38e7ac285db5a96850 100644 (file)
@@ -76,6 +76,7 @@ static int tab_size;
    after `tab_list' is exhausted, the rest of the line is printed
    unchanged.  The first column is column 0. */
 static int *tab_list;
+static size_t n_tabs_allocated;
 
 /* The index of the first invalid element of `tab_list',
    where the next element can be added. */
@@ -121,8 +122,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);
+  if (first_free_tab == n_tabs_allocated)
+    tab_list = x2nrealloc (tab_list, &n_tabs_allocated, sizeof *tab_list);
   tab_list[first_free_tab++] = tabval;
 }