aboutsummaryrefslogtreecommitdiffstats
path: root/support/dfa.c
diff options
context:
space:
mode:
Diffstat (limited to 'support/dfa.c')
-rw-r--r--support/dfa.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/support/dfa.c b/support/dfa.c
index 33de2fb8..7e05a78d 100644
--- a/support/dfa.c
+++ b/support/dfa.c
@@ -617,14 +617,14 @@ static void regexp (struct dfa *dfa);
* PWC points to wint_t, not to wchar_t.
* The last arg is a dfa *D instead of merely a multibyte conversion
state D->mbs.
- * N must be at least 1.
+ * N is idx_t not size_t, and must be at least 1.
* S[N - 1] must be a sentinel byte.
* Shift encodings are not supported.
* The return value is always in the range 1..N.
* D->mbs is always valid afterwards.
* *PWC is always set to something. */
static int
-mbs_to_wchar (wint_t *pwc, char const *s, size_t n, struct dfa *d)
+mbs_to_wchar (wint_t *pwc, char const *s, idx_t n, struct dfa *d)
{
unsigned char uc = s[0];
wint_t wc = d->localeinfo.sbctowc[uc];
@@ -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;
@@ -2165,7 +2165,7 @@ state_index (struct dfa *d, position_set const *s, int context)
for (i = 0; i < s->nelem; ++i)
{
- size_t ind = s->elems[i].index;
+ idx_t ind = s->elems[i].index;
hash ^= ind + s->elems[i].constraint;
}
@@ -2488,7 +2488,7 @@ reorder_tokens (struct dfa *d)
static void
dfaoptimize (struct dfa *d)
{
- char *flags = xzalloc (d->tindex);
+ char *flags = xizalloc (d->tindex);
for (idx_t i = 0; i < d->tindex; i++)
{
@@ -2511,7 +2511,7 @@ dfaoptimize (struct dfa *d)
position_set *merged = &merged0;
alloc_position_set (merged, d->nleaves);
- d->constraints = xcalloc (d->tindex, sizeof *d->constraints);
+ d->constraints = xicalloc (d->tindex, sizeof *d->constraints);
for (idx_t i = 0; i < d->tindex; i++)
if (flags[i] & OPT_QUEUED)
@@ -2614,9 +2614,9 @@ dfaanalyze (struct dfa *d, bool searchflag)
d->searchflag = searchflag;
alloc_position_set (&merged, d->nleaves);
- d->follows = xcalloc (tindex, sizeof *d->follows);
+ d->follows = xicalloc (tindex, sizeof *d->follows);
position_set *backward
- = d->epsilon ? xcalloc (tindex, sizeof *backward) : NULL;
+ = d->epsilon ? xicalloc (tindex, sizeof *backward) : NULL;
for (idx_t i = 0; i < tindex; i++)
{
@@ -2799,7 +2799,7 @@ dfaanalyze (struct dfa *d, bool searchflag)
append (pos, &tmp);
- d->separates = xcalloc (tindex, sizeof *d->separates);
+ d->separates = xicalloc (tindex, sizeof *d->separates);
for (idx_t i = 0; i < tindex; i++)
{
@@ -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;
@@ -3900,7 +3900,7 @@ icatalloc (char *old, char const *new)
if (newsize == 0)
return old;
idx_t oldsize = strlen (old);
- char *result = xrealloc (old, oldsize + newsize + 1);
+ char *result = xirealloc (old, oldsize + newsize + 1);
memcpy (result + oldsize, new, newsize + 1);
return result;
}
@@ -3915,7 +3915,7 @@ freelist (char **cpp)
static char **
enlist (char **cpp, char *new, idx_t len)
{
- new = memcpy (xmalloc (len + 1), new, len);
+ new = memcpy (ximalloc (len + 1), new, len);
new[len] = '\0';
/* Is there already something in the list that's new (or longer)? */
idx_t i;
@@ -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;
@@ -4016,9 +4016,9 @@ allocmust (must *mp, idx_t size)
{
must *new_mp = xmalloc (sizeof *new_mp);
new_mp->in = xzalloc (sizeof *new_mp->in);
- new_mp->left = xzalloc (size);
- new_mp->right = xzalloc (size);
- new_mp->is = xzalloc (size);
+ new_mp->left = xizalloc (size);
+ new_mp->right = xizalloc (size);
+ new_mp->is = xizalloc (size);
new_mp->begline = false;
new_mp->endline = false;
new_mp->prev = mp;
@@ -4169,7 +4169,7 @@ dfamust (struct dfa const *d)
{
idx_t lrlen = strlen (lmp->right);
idx_t rllen = strlen (rmp->left);
- char *tp = xmalloc (lrlen + rllen);
+ char *tp = ximalloc (lrlen + rllen);
memcpy (tp, lmp->right, lrlen);
memcpy (tp + lrlen, rmp->left, rllen);
lmp->in = enlist (lmp->in, tp, lrlen + rllen);