diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-10-31 16:46:02 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-02-10 13:36:46 +0100 |
commit | 51fc54325c55eb3cefafec627d73cc19c220d7ed (patch) | |
tree | 476f20c32019ad9d4f4059031f405f90266c08c2 /src/nvim/api/private/helpers.c | |
parent | 3ff1228f785705a46a0bd24fb5dc2bf76b6dad68 (diff) | |
download | rneovim-51fc54325c55eb3cefafec627d73cc19c220d7ed.tar.gz rneovim-51fc54325c55eb3cefafec627d73cc19c220d7ed.tar.bz2 rneovim-51fc54325c55eb3cefafec627d73cc19c220d7ed.zip |
ui: implement ext_messages
Co-Author: Dongdong Zhou <dzhou121@gmail.com>
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index f5cac82315..19a3368c1c 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -712,6 +712,12 @@ String cbuf_to_string(const char *buf, size_t size) }; } +String cstrn_to_string(const char *str, size_t maxsize) + FUNC_ATTR_NONNULL_ALL +{ + return cbuf_to_string(str, strnlen(str, maxsize)); +} + /// Creates a String using the given C string. Unlike /// cstr_to_string this function DOES NOT copy the C string. /// @@ -726,6 +732,18 @@ String cstr_as_string(char *str) FUNC_ATTR_PURE return (String){ .data = str, .size = strlen(str) }; } +/// Return the owned memory of a ga as a String +/// +/// Reinitializes the ga to a valid empty state. +String ga_take_string(garray_T *ga) +{ + String str = { .data = (char *)ga->ga_data, .size = (size_t)ga->ga_len }; + ga->ga_data = NULL; + ga->ga_len = 0; + ga->ga_maxlen = 0; + return str; +} + /// Collects `n` buffer lines into array `l`, optionally replacing newlines /// with NUL. /// |