Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
28414:e1b7812a4f3b | 28415:813660733869 |
---|---|
5012 | 5012 |
5013 return score; | 5013 return score; |
5014 } | 5014 } |
5015 | 5015 |
5016 /* | 5016 /* |
5017 * Free an array of fuzzy string matches "fuzmatch[count]". | |
5018 */ | |
5019 void | |
5020 fuzmatch_str_free(fuzmatch_str_T *fuzmatch, int count) | |
5021 { | |
5022 int i; | |
5023 | |
5024 if (fuzmatch == NULL) | |
5025 return; | |
5026 for (i = 0; i < count; ++i) | |
5027 vim_free(fuzmatch[i].str); | |
5028 vim_free(fuzmatch); | |
5029 } | |
5030 | |
5031 /* | |
5017 * Copy a list of fuzzy matches into a string list after sorting the matches by | 5032 * Copy a list of fuzzy matches into a string list after sorting the matches by |
5018 * the fuzzy score. Frees the memory allocated for 'fuzmatch'. | 5033 * the fuzzy score. Frees the memory allocated for 'fuzmatch'. |
5019 * Returns OK on success and FAIL on memory allocation failure. | 5034 * Returns OK on success and FAIL on memory allocation failure. |
5020 */ | 5035 */ |
5021 int | 5036 int |
5031 return OK; | 5046 return OK; |
5032 | 5047 |
5033 *matches = ALLOC_MULT(char_u *, count); | 5048 *matches = ALLOC_MULT(char_u *, count); |
5034 if (*matches == NULL) | 5049 if (*matches == NULL) |
5035 { | 5050 { |
5036 for (i = 0; i < count; i++) | 5051 fuzmatch_str_free(fuzmatch, count); |
5037 vim_free(fuzmatch[i].str); | |
5038 vim_free(fuzmatch); | |
5039 return FAIL; | 5052 return FAIL; |
5040 } | 5053 } |
5041 | 5054 |
5042 // Sort the list by the descending order of the match score | 5055 // Sort the list by the descending order of the match score |
5043 if (funcsort) | 5056 if (funcsort) |