summaryrefslogtreecommitdiff
path: root/src/regexp_nfa.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-28 23:08:19 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-28 23:08:19 +0200
commitc799fe206e61f2e2c1231bc46cbe4bb354f3da69 (patch)
tree68b3d2a8bb82519e29fc95f317d2ee02b07f95fa /src/regexp_nfa.c
parentb58a4b938c4bc7e0499700859bd7abba9acc5b11 (diff)
downloadvim-git-c799fe206e61f2e2c1231bc46cbe4bb354f3da69.tar.gz
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type castsv8.1.1414
Problem: Alloc() returning "char_u *" causes a lot of type casts. Solution: Have it return "void *". (Mike Williams) Define ALLOC_ONE() to check the simple allocations.
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r--src/regexp_nfa.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index cb9c801d8..0712f4eee 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -300,7 +300,7 @@ nfa_regcomp_start(
/* Size for postfix representation of expr. */
postfix_size = sizeof(int) * nstate_max;
- post_start = (int *)alloc(postfix_size);
+ post_start = alloc(postfix_size);
if (post_start == NULL)
return FAIL;
post_ptr = post_start;
@@ -516,7 +516,7 @@ realloc_post_list(void)
// For weird patterns the number of states can be very high. Increasing by
// 50% seems a reasonable compromise between memory use and speed.
new_max = nstate_max * 3 / 2;
- new_start = (int *)alloc(new_max * sizeof(int));
+ new_start = ALLOC_MULT(int, new_max);
if (new_start == NULL)
return FAIL;
mch_memmove(new_start, post_start, nstate_max * sizeof(int));
@@ -3214,7 +3214,7 @@ post2nfa(int *postfix, int *end, int nfa_calc_size)
if (nfa_calc_size == FALSE)
{
// Allocate space for the stack. Max states on the stack: "nstate'.
- stack = (Frag_T *)alloc((nstate + 1) * sizeof(Frag_T));
+ stack = ALLOC_MULT(Frag_T, nstate + 1);
if (stack == NULL)
return NULL;
stackp = stack;
@@ -4799,7 +4799,7 @@ addstate_here(
emsg(_(e_maxmempat));
return NULL;
}
- newl = (nfa_thread_T *)alloc(newsize);
+ newl = alloc(newsize);
if (newl == NULL)
return NULL;
l->len = newlen;
@@ -5184,7 +5184,7 @@ recursive_regmatch(
if (*listids == NULL || *listids_len < prog->nstate)
{
vim_free(*listids);
- *listids = (int *)alloc(sizeof(int) * prog->nstate);
+ *listids = ALLOC_MULT(int, prog->nstate);
if (*listids == NULL)
{
emsg(_("E878: (NFA) Could not allocate memory for branch traversal!"));
@@ -5567,9 +5567,9 @@ nfa_regmatch(
/* Allocate memory for the lists of nodes. */
size = (prog->nstate + 1) * sizeof(nfa_thread_T);
- list[0].t = (nfa_thread_T *)alloc(size);
+ list[0].t = alloc(size);
list[0].len = prog->nstate + 1;
- list[1].t = (nfa_thread_T *)alloc(size);
+ list[1].t = alloc(size);
list[1].len = prog->nstate + 1;
if (list[0].t == NULL || list[1].t == NULL)
goto theend;
@@ -7276,7 +7276,7 @@ nfa_regcomp(char_u *expr, int re_flags)
/* allocate the regprog with space for the compiled regexp */
prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1);
- prog = (nfa_regprog_T *)alloc(prog_size);
+ prog = alloc(prog_size);
if (prog == NULL)
goto fail;
state_ptr = prog->state;