]> Savannah Git Hosting - gnulib.git/commitdiff
dfa, etc.: prefer xreallocarray to older name
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 30 May 2021 17:02:20 +0000 (10:02 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 30 May 2021 17:04:47 +0000 (10:04 -0700)
* lib/dfa.c (addtok_mb, realloc_trans_if_necessary, enlist):
* lib/readtokens.c (readtokens):
* tests/uninorm/test-u32-normalize-big.c:
(read_normalization_test_file):
Prefer xreallocarray to the equivalent xnrealloc.
The newer name follows the glibc lead of ‘reallocarray’.

ChangeLog
lib/dfa.c
lib/readtokens.c
tests/uninorm/test-u32-normalize-big.c

index 9b159678a38a2ec55dbc63eb00c9ab895f5eec73..08f9c7b24c2c3ca6882840a3f8d92aefce5a9d5a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2021-05-30  Paul Eggert  <eggert@cs.ucla.edu>
+
+       dfa, etc.: prefer xreallocarray to older name
+       * lib/dfa.c (addtok_mb, realloc_trans_if_necessary, enlist):
+       * lib/readtokens.c (readtokens):
+       * tests/uninorm/test-u32-normalize-big.c:
+       (read_normalization_test_file):
+       Prefer xreallocarray to the equivalent xnrealloc.
+       The newer name follows the glibc lead of ‘reallocarray’.
+
 2021-05-30  Bruno Haible  <bruno@clisp.org>
 
        Write 'LGPLv3+ or GPLv2+' instead of 'LGPLv3+ or GPLv2'.
index 33de2fb82e71ca71b3e017f40d965bed400025bb..5aa4e991357172f64433361ea1e58a4eb12d61d6 100644 (file)
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -1531,8 +1531,8 @@ addtok_mb (struct dfa *dfa, token t, char mbprop)
       dfa->tokens = xpalloc (dfa->tokens, &dfa->talloc, 1, -1,
                              sizeof *dfa->tokens);
       if (dfa->localeinfo.multibyte)
-        dfa->multibyte_prop = xnrealloc (dfa->multibyte_prop, dfa->talloc,
-                                         sizeof *dfa->multibyte_prop);
+        dfa->multibyte_prop = xreallocarray (dfa->multibyte_prop, dfa->talloc,
+                                             sizeof *dfa->multibyte_prop);
     }
   if (dfa->localeinfo.multibyte)
     dfa->multibyte_prop[dfa->tindex] = mbprop;
@@ -2850,13 +2850,13 @@ realloc_trans_if_necessary (struct dfa *d)
       realtrans[0] = realtrans[1] = NULL;
       d->trans = realtrans + 2;
       idx_t newalloc = d->tralloc = newalloc1 - 2;
-      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      d->fails = xreallocarray (d->fails, newalloc, sizeof *d->fails);
+      d->success = xreallocarray (d->success, newalloc, sizeof *d->success);
+      d->newlines = xreallocarray (d->newlines, newalloc, sizeof *d->newlines);
       if (d->localeinfo.multibyte)
         {
           realtrans = d->mb_trans ? d->mb_trans - 2 : NULL;
-          realtrans = xnrealloc (realtrans, newalloc1, sizeof *realtrans);
+          realtrans = xreallocarray (realtrans, newalloc1, sizeof *realtrans);
           if (oldalloc == 0)
             realtrans[0] = realtrans[1] = NULL;
           d->mb_trans = realtrans + 2;
@@ -3938,7 +3938,7 @@ enlist (char **cpp, char *new, idx_t len)
         cpp[i] = NULL;
       }
   /* Add the new string.  */
-  cpp = xnrealloc (cpp, i + 2, sizeof *cpp);
+  cpp = xreallocarray (cpp, i + 2, sizeof *cpp);
   cpp[i] = new;
   cpp[i + 1] = NULL;
   return cpp;
index 091882714ae7072e0af472cdf3bc3d728ec19adc..2c08283e6b8667500dbcb59f60048664cc596358 100644 (file)
@@ -169,7 +169,7 @@ readtokens (FILE *stream,
       if (n_tokens >= sz)
         {
           tokens = x2nrealloc (tokens, &sz, sizeof *tokens);
-          lengths = xnrealloc (lengths, sz, sizeof *lengths);
+          lengths = xreallocarray (lengths, sz, sizeof *lengths);
         }
 
       if (token_length == (size_t) -1)
index e5bad9aa29f0391e62c64b257cf4df3d16b460eb..537dcf96e2671fdf8df08fa6c0c324311ee0991f 100644 (file)
@@ -118,7 +118,7 @@ read_normalization_test_file (const char *filename,
             {
               lines =
                 (struct normalization_test_line *)
-                xnrealloc (lines, lines_length, sizeof (struct normalization_test_line));
+                xreallocarray (lines, lines_length, sizeof *lines);
               file->parts[part_index].lines = lines;
               file->parts[part_index].lines_length = lines_length;
             }
@@ -158,7 +158,7 @@ read_normalization_test_file (const char *filename,
               /* Append uc to the sequence.  */
               sequence =
                 (uint32_t *)
-                xnrealloc (sequence, sequence_length + 2, sizeof (uint32_t));
+                xreallocarray (sequence, sequence_length + 2, sizeof *sequence);
               sequence[sequence_length] = uc;
               sequence_length++;
 
@@ -190,7 +190,7 @@ read_normalization_test_file (const char *filename,
             lines_allocated = 7;
           lines =
             (struct normalization_test_line *)
-            xnrealloc (lines, lines_allocated, sizeof (struct normalization_test_line));
+            xreallocarray (lines, lines_allocated, sizeof *lines);
         }
       lines[lines_length] = line;
       lines_length++;
@@ -200,7 +200,7 @@ read_normalization_test_file (const char *filename,
     {
       lines =
         (struct normalization_test_line *)
-        xnrealloc (lines, lines_length, sizeof (struct normalization_test_line));
+        xreallocarray (lines, lines_length, sizeof *lines);
       file->parts[part_index].lines = lines;
       file->parts[part_index].lines_length = lines_length;
     }