Patch 8.0.1481
Problem:    Clearing a pointer takes two lines.
Solution:   Add vim_clear() to free and clear the pointer.
Files:      src/misc2.c, src/proto/misc2.pro, src/edit.c


*** ../vim-8.0.1480/src/misc2.c 2018-02-03 18:01:33.890107627 +0100
--- src/misc2.c 2018-02-09 12:20:14.615712649 +0100
***************
*** 1836,1841 ****
--- 1836,1854 ----
      }
  }
  
+ /*
+  * Like vim_free(), and also set the pointer to NULL.
+  */
+     void
+ vim_clear(void **x)
+ {
+     if (*x != NULL)
+     {
+       vim_free(*x);
+       *x = NULL;
+     }
+ }
+ 
  #ifndef HAVE_MEMSET
      void *
  vim_memset(void *ptr, int c, size_t size)
***************
*** 5173,5180 ****
        prev2 = prev1;
        prev1 = c1;
  
!         i += MB_PTR2LEN(s1 + i);
!         j += MB_PTR2LEN(s2 + j);
      }
      return s1[i] == s2[j];
  }
--- 5186,5193 ----
        prev2 = prev1;
        prev1 = c1;
  
!       i += MB_PTR2LEN(s1 + i);
!       j += MB_PTR2LEN(s2 + j);
      }
      return s1[i] == s2[j];
  }
***************
*** 5892,5898 ****
            if (c2 == NUL)  /* full match */
                return 0;
            s = q;
!             i = j;
            break;
        }
  
--- 5905,5911 ----
            if (c2 == NUL)  /* full match */
                return 0;
            s = q;
!           i = j;
            break;
        }
  
*** ../vim-8.0.1480/src/proto/misc2.pro 2018-02-03 17:36:22.630091837 +0100
--- src/proto/misc2.pro 2018-02-09 12:20:17.579691658 +0100
***************
*** 46,51 ****
--- 46,52 ----
  void vim_strcat(char_u *to, char_u *from, size_t tosize);
  int copy_option_part(char_u **option, char_u *buf, int maxlen, char 
*sep_chars);
  void vim_free(void *x);
+ void vim_clear(void **x);
  int vim_stricmp(char *s1, char *s2);
  int vim_strnicmp(char *s1, char *s2, size_t len);
  char_u *vim_strchr(char_u *string, int c);
*** ../vim-8.0.1480/src/edit.c  2018-02-09 12:13:28.598612020 +0100
--- src/edit.c  2018-02-09 12:24:25.345942791 +0100
***************
*** 2927,2934 ****
      if (compl_match_array != NULL)
      {
        pum_undisplay();
!       vim_free(compl_match_array);
!       compl_match_array = NULL;
      }
  }
  
--- 2927,2933 ----
      if (compl_match_array != NULL)
      {
        pum_undisplay();
!       vim_clear((void **)&compl_match_array);
      }
  }
  
***************
*** 3430,3439 ****
      compl_T *match;
      int           i;
  
!     vim_free(compl_pattern);
!     compl_pattern = NULL;
!     vim_free(compl_leader);
!     compl_leader = NULL;
  
      if (compl_first_match == NULL)
        return;
--- 3429,3436 ----
      compl_T *match;
      int           i;
  
!     vim_clear((void **)&compl_pattern);
!     vim_clear((void **)&compl_leader);
  
      if (compl_first_match == NULL)
        return;
***************
*** 3465,3477 ****
      compl_cont_status = 0;
      compl_started = FALSE;
      compl_matches = 0;
!     vim_free(compl_pattern);
!     compl_pattern = NULL;
!     vim_free(compl_leader);
!     compl_leader = NULL;
      edit_submode_extra = NULL;
!     vim_free(compl_orig_text);
!     compl_orig_text = NULL;
      compl_enter_selects = FALSE;
      /* clear v:completed_item */
      set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED));
--- 3462,3471 ----
      compl_cont_status = 0;
      compl_started = FALSE;
      compl_matches = 0;
!     vim_clear((void **)&compl_pattern);
!     vim_clear((void **)&compl_leader);
      edit_submode_extra = NULL;
!     vim_clear((void **)&compl_orig_text);
      compl_enter_selects = FALSE;
      /* clear v:completed_item */
      set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED));
***************
*** 5574,5583 ****
        if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
                        -1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK)
        {
!           vim_free(compl_pattern);
!           compl_pattern = NULL;
!           vim_free(compl_orig_text);
!           compl_orig_text = NULL;
            return FAIL;
        }
  
--- 5568,5575 ----
        if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
                        -1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK)
        {
!           vim_clear((void **)&compl_pattern);
!           vim_clear((void **)&compl_orig_text);
            return FAIL;
        }
  
***************
*** 7206,7216 ****
      void
  free_last_insert(void)
  {
!     vim_free(last_insert);
!     last_insert = NULL;
  # ifdef FEAT_INS_EXPAND
!     vim_free(compl_orig_text);
!     compl_orig_text = NULL;
  # endif
  }
  #endif
--- 7198,7206 ----
      void
  free_last_insert(void)
  {
!     vim_clear((void **)&last_insert);
  # ifdef FEAT_INS_EXPAND
!     vim_clear((void **)&compl_orig_text);
  # endif
  }
  #endif
***************
*** 7838,7845 ****
      static void
  replace_flush(void)
  {
!     vim_free(replace_stack);
!     replace_stack = NULL;
      replace_stack_len = 0;
      replace_stack_nr = 0;
  }
--- 7828,7834 ----
      static void
  replace_flush(void)
  {
!     vim_clear((void **)&replace_stack);
      replace_stack_len = 0;
      replace_stack_nr = 0;
  }
*** ../vim-8.0.1480/src/version.c       2018-02-09 12:27:57.012455504 +0100
--- src/version.c       2018-02-09 12:28:59.388018282 +0100
***************
*** 773,774 ****
--- 773,776 ----
  {   /* Add new patch number below this line */
+ /**/
+     1481,
  /**/

-- 
A real patriot is the fellow who gets a parking ticket and rejoices
that the system works.


 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui