mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 01:46:29 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user