Mercurial > vim
diff src/search.c @ 28415:813660733869 v8.2.4732
patch 8.2.4732: duplicate code to free fuzzy matches
Commit: https://github.com/vim/vim/commit/c6e0a5e98c07d898e829d62bd938b1cc1fd37e94
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 10 18:09:06 2022 +0100
patch 8.2.4732: duplicate code to free fuzzy matches
Problem: Duplicate code to free fuzzy matches.
Solution: Bring back fuzmatch_str_free().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 10 Apr 2022 19:15:03 +0200 |
parents | 473cfd79bcd8 |
children | 2ade724b3f45 |
line wrap: on
line diff
--- a/src/search.c +++ b/src/search.c @@ -5014,6 +5014,21 @@ fuzzy_match_str(char_u *str, char_u *pat } /* + * 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,9 +5048,7 @@ fuzzymatches_to_strmatches( *matches = ALLOC_MULT(char_u *, count); if (*matches == NULL) { - for (i = 0; i < count; i++) - vim_free(fuzmatch[i].str); - vim_free(fuzmatch); + fuzmatch_str_free(fuzmatch, count); return FAIL; }