aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'util.h')
-rw-r--r--util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/util.h b/util.h
index a53deda..9048c82 100644
--- a/util.h
+++ b/util.h
@@ -23,4 +23,15 @@ static inline bool addu(size_t a, size_t b, size_t *c) {
}
#endif
+#if !HAVE_MEMRCHR
+/* MIT licensed implementation from musl libc */
+static void *memrchr(const void *m, int c, size_t n)
+{
+ const unsigned char *s = m;
+ c = (unsigned char)c;
+ while (n--) if (s[n]==c) return (void *)(s+n);
+ return 0;
+}
#endif
+
+#endif /* UTIL_H */