mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 23:08:16 +00:00
refactor: add function xstrnsave
xstrnsave is a clone of vim_strnsave that uses char* instead of char_u*. Its purpose short-term is to help reduce the number of casts and for long-term to replace vim_strnsave as the need to use char_u is eliminated.
This commit is contained in:
@@ -67,6 +67,13 @@ char_u *vim_strnsave(const char_u *string, size_t len)
|
||||
return (char_u *)strncpy(xmallocz(len), (char *)string, len);
|
||||
}
|
||||
|
||||
/// A clone of vim_strnsave() that uses char* instead of char_u*
|
||||
char *xstrnsave(const char *string, size_t len)
|
||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
return strncpy(xmallocz(len), string, len); // NOLINT(runtime/printf)
|
||||
}
|
||||
|
||||
/*
|
||||
* Same as vim_strsave(), but any characters found in esc_chars are preceded
|
||||
* by a backslash.
|
||||
|
Reference in New Issue
Block a user