diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-10 08:39:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 08:39:21 +0800 |
commit | cd63a9addd6e1114c3524fa041ece560550cfe7b (patch) | |
tree | 846797f471b5de4c230838620ceaeda860de9e17 /src/nvim/menu.c | |
parent | ae8ca79920a8d0e928ac1502a10d1d063a06cae5 (diff) | |
download | rneovim-cd63a9addd6e1114c3524fa041ece560550cfe7b.tar.gz rneovim-cd63a9addd6e1114c3524fa041ece560550cfe7b.tar.bz2 rneovim-cd63a9addd6e1114c3524fa041ece560550cfe7b.zip |
refactor: change some xstrndup() and xstrnsave() to xmemdupz() (#25959)
When the given length is exactly the number of bytes to copy, xmemdupz()
makes the intention clearer.
Diffstat (limited to 'src/nvim/menu.c')
-rw-r--r-- | src/nvim/menu.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 5eb8b41015..5fa731141e 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -1313,7 +1313,7 @@ static char *menu_text(const char *str, int *mnemonic, char **actext) *actext = xstrdup(p + 1); } assert(p >= str); - text = xstrnsave(str, (size_t)(p - str)); + text = xmemdupz(str, (size_t)(p - str)); } else { text = xstrdup(str); } @@ -1736,7 +1736,7 @@ void ex_menutranslate(exarg_T *eap) from = xstrdup(from); from_noamp = menu_text(from, NULL, NULL); assert(arg >= to); - to = xstrnsave(to, (size_t)(arg - to)); + to = xmemdupz(to, (size_t)(arg - to)); menu_translate_tab_and_shift(from); menu_translate_tab_and_shift(to); menu_unescape_name(from); |