aboutsummaryrefslogtreecommitdiffstats
path: root/memelemmove.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-11-25 14:17:49 +0100
committerMattias Andrée <maandree@kth.se>2018-11-25 14:17:49 +0100
commite2dc7cf9c966d4c94b7556c1c2ada8d170715654 (patch)
tree78733ab53fb0e1d185773d23f0f5ccd373be2bc1 /memelemmove.c
parentAdd man pages (diff)
downloadlibsimple-e2dc7cf9c966d4c94b7556c1c2ada8d170715654.tar.gz
libsimple-e2dc7cf9c966d4c94b7556c1c2ada8d170715654.tar.bz2
libsimple-e2dc7cf9c966d4c94b7556c1c2ada8d170715654.tar.xz
Fix consistence in memelem functions
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--memelemmove.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/memelemmove.c b/memelemmove.c
index 90bf2fb..d810ba4 100644
--- a/memelemmove.c
+++ b/memelemmove.c
@@ -50,35 +50,35 @@ memelemmove64(uint64_t *restrict d, const uint64_t *restrict s, uint64_t elem, s
static char *
-memelemmovex(char *restrict d, const char *restrict s, const char *restrict elem, size_t size, size_t n)
+memelemmovex(char *restrict d, const char *restrict s, const char *restrict elem, size_t width, size_t n)
{
char *p;
size_t i;
if (d <= s) {
- for (; n; s += size, n--) {
- for (i = 0; i < size; i++)
+ for (; n; s += width, n--) {
+ for (i = 0; i < width; i++)
d[i] = s[i];
- for (i = 0; i < size; i++)
+ for (i = 0; i < width; i++)
if (d[i] != elem[i])
goto next_forwards;
- d += size;
+ d += width;
return d;
next_forwards:
- d += size;
+ d += width;
}
return NULL;
} else {
for (p = *(char **)(void *)&s; n; n--) {
- for (i = 0; i < size; i++)
+ for (i = 0; i < width; i++)
if (p[i] != elem[i])
goto next_backwards;
- p += size;
+ p += width;
n = (size_t)(p - s);
p = &d[n];
goto out_backwards;
next_backwards:
- p += size;
+ p += width;
}
n = (size_t)(p - s);
p = NULL;
@@ -93,9 +93,9 @@ memelemmovex(char *restrict d, const char *restrict s, const char *restrict elem
void *
-libsimple_memelemmove(void *d, const void *s, const void *restrict elem, size_t size, size_t n) /* TODO man */
+libsimple_memelemmove(void *d, const void *s, const void *restrict elem, size_t width, size_t n) /* TODO man */
{
- switch (size) {
+ switch (width) {
case 0:
return d;
case 1:
@@ -107,7 +107,7 @@ libsimple_memelemmove(void *d, const void *s, const void *restrict elem, size_t
case 8:
return memelemmove64(d, s, *(const uint64_t *)elem, n);
default:
- return memelemmovex(d, s, elem, size, n);
+ return memelemmovex(d, s, elem, width, n);
}
}