aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/cmdhist.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-22 06:54:09 +0800
committerGitHub <noreply@github.com>2024-05-22 06:54:09 +0800
commit2d8cb1bc9bb06920ed7423861fb20038848e79ae (patch)
tree6a9e75cb83c78c1828ef96fda8d6b1a607a461d3 /src/nvim/cmdhist.c
parent879d17ea8d62c199ea0c91c5f37a4f25495be7ce (diff)
parent59fe8ffdeaacc08b811aa97d270daec6d6ed2769 (diff)
downloadrneovim-2d8cb1bc9bb06920ed7423861fb20038848e79ae.tar.gz
rneovim-2d8cb1bc9bb06920ed7423861fb20038848e79ae.tar.bz2
rneovim-2d8cb1bc9bb06920ed7423861fb20038848e79ae.zip
Merge pull request #28905 from zeertzjq/vim-9.1.0426
vim-patch:9.1.{0426,0428}: too many strlen() calls in search.c
Diffstat (limited to 'src/nvim/cmdhist.c')
-rw-r--r--src/nvim/cmdhist.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c
index 6a9290270a..eb1658aa1f 100644
--- a/src/nvim/cmdhist.c
+++ b/src/nvim/cmdhist.c
@@ -294,7 +294,7 @@ static int last_maptick = -1; // last seen maptick
/// @param histype may be one of the HIST_ values.
/// @param in_map consider maptick when inside a mapping
/// @param sep separator character used (search hist)
-void add_to_history(int histype, const char *new_entry, int in_map, int sep)
+void add_to_history(int histype, const char *new_entry, size_t new_entrylen, bool in_map, int sep)
{
histentry_T *hisptr;
@@ -334,11 +334,10 @@ void add_to_history(int histype, const char *new_entry, int in_map, int sep)
hist_free_entry(hisptr);
// Store the separator after the NUL of the string.
- size_t len = strlen(new_entry);
- hisptr->hisstr = xstrnsave(new_entry, len + 2);
+ hisptr->hisstr = xstrnsave(new_entry, new_entrylen + 2);
hisptr->timestamp = os_time();
hisptr->additional_elements = NULL;
- hisptr->hisstr[len + 1] = (char)sep;
+ hisptr->hisstr[new_entrylen + 1] = (char)sep;
hisptr->hisnum = ++hisnum[histype];
if (histype == HIST_SEARCH && in_map) {
@@ -536,7 +535,7 @@ void f_histadd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
init_history();
- add_to_history(histype, str, false, NUL);
+ add_to_history(histype, str, strlen(str), false, NUL);
rettv->vval.v_number = true;
}