mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 07:28:34 +00:00
Add helper cstr_as_string()
- Add nocopy helper alternative to cstr_to_string
This commit is contained in:

committed by
Thiago de Arruda

parent
4702b8a716
commit
d8beb77b1b
@@ -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;
|
||||
|
Reference in New Issue
Block a user