aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/memory.c')
-rw-r--r--src/nvim/memory.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index a13091793c..df6c81fe0d 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -213,6 +213,18 @@ void *xmemdupz(const void *data, size_t len)
return memcpy(xmallocz(len), data, len);
}
+#ifndef HAVE_STRNLEN
+size_t xstrnlen(const char *s, size_t n)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
+{
+ const char *end = memchr(s, '\0', n);
+ if (end == NULL) {
+ return n;
+ }
+ return (size_t)(end - s);
+}
+#endif
+
/// A version of strchr() that returns a pointer to the terminating NUL if it
/// doesn't find `c`.
///
@@ -496,13 +508,6 @@ bool strequal(const char *a, const char *b)
return (a == NULL && b == NULL) || (a && b && strcmp(a, b) == 0);
}
-/// Case-insensitive `strequal`.
-bool striequal(const char *a, const char *b)
- FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
-{
- return (a == NULL && b == NULL) || (a && b && STRICMP(a, b) == 0);
-}
-
// Avoid repeating the error message many times (they take 1 second each).
// Did_outofmem_msg is reset when a character is read.
void do_outofmem_msg(size_t size)