Patch 7.3.1018
Problem:    New regexp engine wastes memory.
Solution:   Allocate prog with actual number of states, not estimated maximum
            number of sates.
Files:      src/regexp_nfa.c


*** ../vim-7.3.1017/src/regexp_nfa.c    2013-05-25 20:19:45.000000000 +0200
--- src/regexp_nfa.c    2013-05-25 20:57:21.000000000 +0200
***************
*** 3758,3764 ****
      char_u    *expr;
      int               re_flags;
  {
!     nfa_regprog_T     *prog;
      size_t            prog_size;
      int                       *postfix;
  
--- 3758,3764 ----
      char_u    *expr;
      int               re_flags;
  {
!     nfa_regprog_T     *prog = NULL;
      size_t            prog_size;
      int                       *postfix;
  
***************
*** 3774,3788 ****
      if (nfa_regcomp_start(expr, re_flags) == FAIL)
        return NULL;
  
-     /* Space for compiled regexp */
-     prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * nstate_max;
-     prog = (nfa_regprog_T *)lalloc(prog_size, TRUE);
-     if (prog == NULL)
-       goto fail;
-     vim_memset(prog, 0, prog_size);
- 
      /* Build postfix form of the regexp. Needed to build the NFA
!      * (and count its size) */
      postfix = re2post();
      if (postfix == NULL)
        goto fail;          /* Cascaded (syntax?) error */
--- 3774,3781 ----
      if (nfa_regcomp_start(expr, re_flags) == FAIL)
        return NULL;
  
      /* Build postfix form of the regexp. Needed to build the NFA
!      * (and count its size). */
      postfix = re2post();
      if (postfix == NULL)
        goto fail;          /* Cascaded (syntax?) error */
***************
*** 3809,3814 ****
--- 3802,3814 ----
       * Count number of NFA states in "nstate". Do not build the NFA.
       */
      post2nfa(postfix, post_ptr, TRUE);
+ 
+     /* Space for compiled regexp */
+     prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * nstate;
+     prog = (nfa_regprog_T *)lalloc(prog_size, TRUE);
+     if (prog == NULL)
+       goto fail;
+     vim_memset(prog, 0, prog_size);
      state_ptr = prog->state;
  
      /*
*** ../vim-7.3.1017/src/version.c       2013-05-25 20:19:45.000000000 +0200
--- src/version.c       2013-05-25 21:17:39.000000000 +0200
***************
*** 730,731 ****
--- 730,733 ----
  {   /* Add new patch number below this line */
+ /**/
+     1018,
  /**/

-- 
Sometimes you can protect millions of dollars in your budget simply by buying
a bag of cookies, dropping it on the budget anylyst's desk, and saying
something deeply personal such as "How was your weekend, big guy?"
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui