diff options
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 354a74d19a..f6fb46e1d1 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -343,6 +343,20 @@ String cstr_to_string(const char *str) }; } +/// Creates a String using the given C string. Unlike +/// cstr_to_string this function DOES NOT copy the C string. +/// +/// @param str the C string to use +/// @return The resulting String, or an empty String if +/// str was NULL +String cstr_as_string(char *str) FUNC_ATTR_PURE +{ + if (str == NULL) { + return (String) STRING_INIT; + } + return (String) {.data = str, .size = strlen(str)}; +} + bool object_to_vim(Object obj, typval_T *tv, Error *err) { tv->v_type = VAR_UNKNOWN; |