Patch 8.2.4732
Problem:    Duplicate code to free fuzzy matches.
Solution:   Bring back fuzmatch_str_free().
Files:      src/search.c, src/proto/search.pro, src/cmdexpand.c


*** ../vim-8.2.4731/src/search.c        2022-04-10 11:26:00.941539608 +0100
--- src/search.c        2022-04-10 18:05:34.069224167 +0100
***************
*** 5014,5019 ****
--- 5014,5034 ----
  }
  
  /*
+  * Free an array of fuzzy string matches "fuzmatch[count]".
+  */
+     void
+ fuzmatch_str_free(fuzmatch_str_T *fuzmatch, int count)
+ {
+     int i;
+ 
+     if (fuzmatch == NULL)
+       return;
+     for (i = 0; i < count; ++i)
+       vim_free(fuzmatch[i].str);
+     vim_free(fuzmatch);
+ }
+ 
+ /*
   * Copy a list of fuzzy matches into a string list after sorting the matches 
by
   * the fuzzy score. Frees the memory allocated for 'fuzmatch'.
   * Returns OK on success and FAIL on memory allocation failure.
***************
*** 5033,5041 ****
      *matches = ALLOC_MULT(char_u *, count);
      if (*matches == NULL)
      {
!       for (i = 0; i < count; i++)
!           vim_free(fuzmatch[i].str);
!       vim_free(fuzmatch);
        return FAIL;
      }
  
--- 5048,5054 ----
      *matches = ALLOC_MULT(char_u *, count);
      if (*matches == NULL)
      {
!       fuzmatch_str_free(fuzmatch, count);
        return FAIL;
      }
  
*** ../vim-8.2.4731/src/proto/search.pro        2022-04-10 11:26:00.941539608 
+0100
--- src/proto/search.pro        2022-04-10 18:07:59.620302840 +0100
***************
*** 41,45 ****
  void f_matchfuzzy(typval_T *argvars, typval_T *rettv);
  void f_matchfuzzypos(typval_T *argvars, typval_T *rettv);
  int fuzzy_match_str(char_u *str, char_u *pat);
! int fuzzymatches_to_strmatches(fuzmatch_str_T *fuzmatch, char_u ***matches, 
int       count, int funcsort);
  /* vim: set ft=c : */
--- 41,46 ----
  void f_matchfuzzy(typval_T *argvars, typval_T *rettv);
  void f_matchfuzzypos(typval_T *argvars, typval_T *rettv);
  int fuzzy_match_str(char_u *str, char_u *pat);
! void fuzmatch_str_free(fuzmatch_str_T *fuzmatch, int count);
! int fuzzymatches_to_strmatches(fuzmatch_str_T *fuzmatch, char_u ***matches, 
int count, int funcsort);
  /* vim: set ft=c : */
*** ../vim-8.2.4731/src/cmdexpand.c     2022-03-24 11:22:07.215294108 +0000
--- src/cmdexpand.c     2022-04-10 18:07:56.184322341 +0100
***************
*** 2877,2889 ****
                ga_clear_strings(&ga);
                return FAIL;
            }
! 
!           for (i = 0; i < ga.ga_len; ++i)
!           {
!               fuzmatch = &((fuzmatch_str_T *)ga.ga_data)[i];
!               vim_free(fuzmatch->str);
!           }
!           ga_clear(&ga);
            return FAIL;
        }
  
--- 2877,2883 ----
                ga_clear_strings(&ga);
                return FAIL;
            }
!           fuzmatch_str_free(ga.ga_data, ga.ga_len);
            return FAIL;
        }
  
*** ../vim-8.2.4731/src/version.c       2022-04-10 17:59:23.343015280 +0100
--- src/version.c       2022-04-10 18:08:34.180112077 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4732,
  /**/

-- 
Bad programs can be written in any language.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220410170955.D52C91C0463%40moolenaar.net.

Raspunde prin e-mail lui