summaryrefslogtreecommitdiff
path: root/src/misc2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc2.c')
-rw-r--r--src/misc2.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/misc2.c b/src/misc2.c
index 3834979b8..07bdf85f8 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1351,6 +1351,20 @@ vim_strnsave(char_u *string, int len)
}
/*
+ * Copy "p[len]" into allocated memory, ignoring NUL characters.
+ * Returns NULL when out of memory.
+ */
+ char_u *
+vim_memsave(char_u *p, int len)
+{
+ char_u *ret = alloc((unsigned)len);
+
+ if (ret != NULL)
+ mch_memmove(ret, p, (size_t)len);
+ return ret;
+}
+
+/*
* Same as vim_strsave(), but any characters found in esc_chars are preceded
* by a backslash.
*/