From fcfe59c1f2219408ac2a9cd84b386816ff252221 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 11 Jun 2022 16:37:09 +0200 Subject: Fix warnings, replace some static inline with inline + extern inline, and fix glibc support --- memelem.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'memelem.c') diff --git a/memelem.c b/memelem.c index 7d9231d..3344cd8 100644 --- a/memelem.c +++ b/memelem.c @@ -8,46 +8,46 @@ libsimple_memelem(const void *hay_, const void *sub_, size_t width, size_t n) { switch (width) { case 0: - return (void *)hay_; + return REMOVE_CONST(hay_, void *); case 1: - return memchr(hay_, *(char *)sub_, n); + return memchr(hay_, *(const char *)sub_, n); case 2: { - uint16_t *hay = (void *)hay_; - uint16_t sub = *(uint16_t *)sub_; + const uint16_t *hay = hay_; + uint16_t sub = *(const uint16_t *)sub_; for (; n--; hay++) if (*hay == sub) - return hay; + return REMOVE_CONST(hay, uint16_t *); break; } case 4: { - uint32_t *hay = (void *)hay_; - uint32_t sub = *(uint32_t *)sub_; + const uint32_t *hay = hay_; + uint32_t sub = *(const uint32_t *)sub_; for (; n--; hay++) if (*hay == sub) - return hay; + return REMOVE_CONST(hay, uint32_t *); break; } case 8: { - uint64_t *hay = (void *)hay_; - uint64_t sub = *(uint64_t *)sub_; + const uint64_t *hay = hay_; + uint64_t sub = *(const uint64_t *)sub_; for (; n--; hay++) if (*hay == sub) - return hay; + return REMOVE_CONST(hay, uint64_t *); break; } default: { - char *hay = (void *)hay_; + const char *hay = hay_; const char *sub = sub_; size_t i; for (; n--; hay += width) { for (i = 0; i < width; i++) if (hay[i] != sub[i]) goto next; - return hay; + return REMOVE_CONST(hay, char *); next:; } break; -- cgit v1.2.3-70-g09d2