comparison src/regexp_nfa.c @ 16768:695d9ef00b03 v8.1.1386

patch 8.1.1386: unessesary type casts for lalloc() commit https://github.com/vim/vim/commit/18a4ba29aeccb9841d5bfdd2eaaffdfae2f15ced Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 24 19:39:03 2019 +0200 patch 8.1.1386: unessesary type casts for lalloc() Problem: Unessesary type casts for lalloc(). Solution: Remove type casts. Change lalloc(size, TRUE) to alloc(size).
author Bram Moolenaar <Bram@vim.org>
date Fri, 24 May 2019 19:45:05 +0200
parents 38a323a6fd18
children fc58fee685e2
comparison
equal deleted inserted replaced
16767:3959544fc067 16768:695d9ef00b03
298 nstate_max += 1000; 298 nstate_max += 1000;
299 299
300 /* Size for postfix representation of expr. */ 300 /* Size for postfix representation of expr. */
301 postfix_size = sizeof(int) * nstate_max; 301 postfix_size = sizeof(int) * nstate_max;
302 302
303 post_start = (int *)lalloc(postfix_size, TRUE); 303 post_start = (int *)alloc(postfix_size);
304 if (post_start == NULL) 304 if (post_start == NULL)
305 return FAIL; 305 return FAIL;
306 post_ptr = post_start; 306 post_ptr = post_start;
307 post_end = post_start + nstate_max; 307 post_end = post_start + nstate_max;
308 rex.nfa_has_zend = FALSE; 308 rex.nfa_has_zend = FALSE;
514 int *old_start; 514 int *old_start;
515 515
516 // For weird patterns the number of states can be very high. Increasing by 516 // For weird patterns the number of states can be very high. Increasing by
517 // 50% seems a reasonable compromise between memory use and speed. 517 // 50% seems a reasonable compromise between memory use and speed.
518 new_max = nstate_max * 3 / 2; 518 new_max = nstate_max * 3 / 2;
519 new_start = (int *)lalloc(new_max * sizeof(int), TRUE); 519 new_start = (int *)alloc(new_max * sizeof(int));
520 if (new_start == NULL) 520 if (new_start == NULL)
521 return FAIL; 521 return FAIL;
522 mch_memmove(new_start, post_start, nstate_max * sizeof(int)); 522 mch_memmove(new_start, post_start, nstate_max * sizeof(int));
523 old_start = post_start; 523 old_start = post_start;
524 post_start = new_start; 524 post_start = new_start;
3212 } 3212 }
3213 3213
3214 if (nfa_calc_size == FALSE) 3214 if (nfa_calc_size == FALSE)
3215 { 3215 {
3216 // Allocate space for the stack. Max states on the stack: "nstate'. 3216 // Allocate space for the stack. Max states on the stack: "nstate'.
3217 stack = (Frag_T *)lalloc((nstate + 1) * sizeof(Frag_T), TRUE); 3217 stack = (Frag_T *)alloc((nstate + 1) * sizeof(Frag_T));
3218 if (stack == NULL) 3218 if (stack == NULL)
3219 return NULL; 3219 return NULL;
3220 stackp = stack; 3220 stackp = stack;
3221 stack_end = stack + (nstate + 1); 3221 stack_end = stack + (nstate + 1);
3222 } 3222 }
5182 /* Already calling nfa_regmatch() recursively. Save the lastlist[1] 5182 /* Already calling nfa_regmatch() recursively. Save the lastlist[1]
5183 * values and clear them. */ 5183 * values and clear them. */
5184 if (*listids == NULL || *listids_len < prog->nstate) 5184 if (*listids == NULL || *listids_len < prog->nstate)
5185 { 5185 {
5186 vim_free(*listids); 5186 vim_free(*listids);
5187 *listids = (int *)lalloc(sizeof(int) * prog->nstate, TRUE); 5187 *listids = (int *)alloc(sizeof(int) * prog->nstate);
5188 if (*listids == NULL) 5188 if (*listids == NULL)
5189 { 5189 {
5190 emsg(_("E878: (NFA) Could not allocate memory for branch traversal!")); 5190 emsg(_("E878: (NFA) Could not allocate memory for branch traversal!"));
5191 return 0; 5191 return 0;
5192 } 5192 }
5565 nfa_match = FALSE; 5565 nfa_match = FALSE;
5566 5566
5567 /* Allocate memory for the lists of nodes. */ 5567 /* Allocate memory for the lists of nodes. */
5568 size = (prog->nstate + 1) * sizeof(nfa_thread_T); 5568 size = (prog->nstate + 1) * sizeof(nfa_thread_T);
5569 5569
5570 list[0].t = (nfa_thread_T *)lalloc(size, TRUE); 5570 list[0].t = (nfa_thread_T *)alloc(size);
5571 list[0].len = prog->nstate + 1; 5571 list[0].len = prog->nstate + 1;
5572 list[1].t = (nfa_thread_T *)lalloc(size, TRUE); 5572 list[1].t = (nfa_thread_T *)alloc(size);
5573 list[1].len = prog->nstate + 1; 5573 list[1].len = prog->nstate + 1;
5574 if (list[0].t == NULL || list[1].t == NULL) 5574 if (list[0].t == NULL || list[1].t == NULL)
5575 goto theend; 5575 goto theend;
5576 5576
5577 #ifdef ENABLE_LOG 5577 #ifdef ENABLE_LOG
7274 */ 7274 */
7275 post2nfa(postfix, post_ptr, TRUE); 7275 post2nfa(postfix, post_ptr, TRUE);
7276 7276
7277 /* allocate the regprog with space for the compiled regexp */ 7277 /* allocate the regprog with space for the compiled regexp */
7278 prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1); 7278 prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1);
7279 prog = (nfa_regprog_T *)lalloc(prog_size, TRUE); 7279 prog = (nfa_regprog_T *)alloc(prog_size);
7280 if (prog == NULL) 7280 if (prog == NULL)
7281 goto fail; 7281 goto fail;
7282 state_ptr = prog->state; 7282 state_ptr = prog->state;
7283 prog->re_in_use = FALSE; 7283 prog->re_in_use = FALSE;
7284 7284