From b389733ab0fa46f2cecd302cc5826fc7dc322c8e Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Sat, 6 Dec 2025 08:54:34 -0700 Subject: util: replace memrchr with internal version The amount of code we need to detect if this is present and handle the fallback is more than if we just provide it ourselves. Also we are passing in a difference of pointers so the argument type should be ptrdiff_t. This avoids a C brain damage of having unsigned size type which can wrap around if the caller is careful. --- util.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'util.h') diff --git a/util.h b/util.h index 08a44a8..d84846a 100644 --- a/util.h +++ b/util.h @@ -23,17 +23,6 @@ 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 - /* Needed for building on GNU Hurd */ #ifndef PIPE_BUF -- cgit v1.2.3