refactor: move function macros out of vim_defs.h (#26300)

This commit is contained in:
zeertzjq
2023-11-29 23:10:21 +08:00
committed by GitHub
parent 18c1fd8e9d
commit 86cc791deb
22 changed files with 86 additions and 89 deletions

View File

@@ -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)