aboutsummaryrefslogtreecommitdiffstats
path: root/memrelem.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-08-18 09:58:23 +0200
committerMattias Andrée <maandree@kth.se>2024-08-18 09:58:23 +0200
commita69f0f613687edf6c1f1ee83b462f77e8ea3c9a9 (patch)
treed976683461a0f427d2f1ef79a8732a048dd0c67b /memrelem.c
parentMerge tag '1.3' into since (diff)
parentUpdate VERSION_MINOR (diff)
downloadlibsimple-a69f0f613687edf6c1f1ee83b462f77e8ea3c9a9.tar.gz
libsimple-a69f0f613687edf6c1f1ee83b462f77e8ea3c9a9.tar.bz2
libsimple-a69f0f613687edf6c1f1ee83b462f77e8ea3c9a9.tar.xz
Merge tag '1.4' into since
Version 1.4
Diffstat (limited to 'memrelem.c')
-rw-r--r--memrelem.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/memrelem.c b/memrelem.c
index 5b9cf8f..c243671 100644
--- a/memrelem.c
+++ b/memrelem.c
@@ -1,5 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#include "libsimple.h"
+#include "common.h"
#ifndef TEST
@@ -8,46 +8,46 @@ libsimple_memrelem(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:
{
- uint8_t *hay = (void *)hay_;
- uint8_t sub = *(uint8_t *)sub_;
+ const uint8_t *hay = hay_;
+ uint8_t sub = *(const uint8_t *)sub_;
for (hay += n; n--;)
if (*--hay == sub)
- return hay;
+ return REMOVE_CONST(hay, uint8_t *);
break;
}
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 (hay += n; n--;)
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 (hay += n; n--;)
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 (hay += n; n--;)
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 (hay += n * width; n--;) {
@@ -55,7 +55,7 @@ libsimple_memrelem(const void *hay_, const void *sub_, size_t width, size_t n)
for (i = 0; i < width; i++)
if (hay[i] != sub[i])
goto next;
- return hay;
+ return REMOVE_CONST(hay, void *);
next:;
}
break;