aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2017-08-16 12:19:29 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2017-10-26 20:28:47 +0200
commit22402fb99d05191cf140293cfb5f67902e78a8a8 (patch)
tree29868ae79bee033268489db3d0755d0393b7a581 /src/nvim/api/private/helpers.c
parent5ad591ef2d0ef184f78c728b1774c2a55fe2e581 (diff)
downloadrneovim-22402fb99d05191cf140293cfb5f67902e78a8a8.tar.gz
rneovim-22402fb99d05191cf140293cfb5f67902e78a8a8.tar.bz2
rneovim-22402fb99d05191cf140293cfb5f67902e78a8a8.zip
ext_cmdline: add support for highlighting
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index f00fbf69ea..2944925a9c 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -703,6 +703,23 @@ String cstr_to_string(const char *str)
};
}
+/// Copies buffer to an allocated String.
+/// The resulting string is also NUL-terminated, to facilitate interoperating
+/// with code using C strings.
+///
+/// @param buf the buffer to copy
+/// @param size length of the buffer
+/// @return the resulting String, if the input string was NULL, an
+/// empty String is returned
+String cbuf_to_string(const char *buf, size_t size)
+ FUNC_ATTR_NONNULL_ALL
+{
+ return (String) {
+ .data = xmemdupz(buf, size),
+ .size = size
+ };
+}
+
/// Creates a String using the given C string. Unlike
/// cstr_to_string this function DOES NOT copy the C string.
///