return end - dst;
}
-static inline size_t xstrlen(const char *s)
+static inline size_t xstrlen(const char *restrict s)
{
#if !defined(__GLIBC__)
return strlen(s); // NOLINT
#endif
}
-static char *xstrdup(const char *s)
+static char *xstrdup(const char *restrict s)
{
size_t len = xstrlen(s) + 1;
char *ptr = malloc(len);
* And we are NOT expecting a '/' at the end.
* Ideally 0 < n <= xstrlen(s).
*/
-static void *xmemrchr(uchar *s, uchar ch, size_t n)
+static void *xmemrchr(uchar *restrict s, uchar ch, size_t n)
{
+#if defined(__GLIBC__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+ return memrchr(s, ch, n);
+#else
+
if (!s || !n)
return NULL;
while (s != ptr);
return NULL;
+#endif
}
/* Assumes both the paths passed are directories */