summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--lib/dfa.c14
-rw-r--r--lib/readtokens.c2
-rw-r--r--tests/uninorm/test-u32-normalize-big.c8
4 files changed, 22 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 9b159678a3..08f9c7b24c 100644
--- 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'.
diff --git a/lib/dfa.c b/lib/dfa.c
index 33de2fb82e..5aa4e99135 100644
--- 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;
diff --git a/lib/readtokens.c b/lib/readtokens.c
index 091882714a..2c08283e6b 100644
--- a/lib/readtokens.c
+++ b/lib/readtokens.c
@@ -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)
diff --git a/tests/uninorm/test-u32-normalize-big.c b/tests/uninorm/test-u32-normalize-big.c
index e5bad9aa29..537dcf96e2 100644
--- a/tests/uninorm/test-u32-normalize-big.c
+++ b/tests/uninorm/test-u32-normalize-big.c
@@ -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;
}