diff options
author | Dundar Goc <gocdundar@gmail.com> | 2022-04-15 19:49:06 +0200 |
---|---|---|
committer | Dundar Goc <gocdundar@gmail.com> | 2022-04-16 18:09:26 +0200 |
commit | 88270a57358e4009537de9435c19fcb17e66ffdd (patch) | |
tree | 87216094e11d56b9058ac23de43238ff3a469ff6 /src/nvim/strings.c | |
parent | 7a2fcbbbecc96c0179aa9449a1d4e3b5d936a054 (diff) | |
download | rneovim-88270a57358e4009537de9435c19fcb17e66ffdd.tar.gz rneovim-88270a57358e4009537de9435c19fcb17e66ffdd.tar.bz2 rneovim-88270a57358e4009537de9435c19fcb17e66ffdd.zip |
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.
Diffstat (limited to 'src/nvim/strings.c')
-rw-r--r-- | src/nvim/strings.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 9d4c64e4b1..848044ee7c 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -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. |