summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2017-07-23 21:46:02 +0200
committerDenys Vlasenko2017-07-23 21:46:34 +0200
commit5ace96a71304c2d5d3b8b864df9b4b8ca40f417c (patch)
treed773109b464a971aaac671548250140607d3523c
parente4f6bfd6fec87e8eb77f1a9fe34b8b7884ef9748 (diff)
downloadbusybox-5ace96a71304c2d5d3b8b864df9b4b8ca40f417c.zip
busybox-5ace96a71304c2d5d3b8b864df9b4b8ca40f417c.tar.gz
ash: use mempcpy() in more places
Most changes are taken from dash. function old new delta single_quote 127 129 +2 stack_nputstr 28 29 +1 path_advance 209 202 -7 rmescapes 346 308 -38 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 3/-45) Total: -42 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c
index c8b2adf..fa03f8a 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1658,7 +1658,7 @@ static char *
stack_nputstr(const char *s, size_t n, char *p)
{
p = makestrspace(n, p);
- p = (char *)memcpy(p, s, n) + n;
+ p = (char *)mempcpy(p, s, n);
return p;
}
@@ -1761,7 +1761,7 @@ single_quote(const char *s)
q = p = makestrspace(len + 3, p);
*q++ = '\'';
- q = (char *)memcpy(q, s, len) + len;
+ q = (char *)mempcpy(q, s, len) + len;
*q++ = '\'';
s += len;
@@ -1775,7 +1775,7 @@ single_quote(const char *s)
q = p = makestrspace(len + 3, p);
*q++ = '"';
- q = (char *)memcpy(q, s - len, len) + len;
+ q = (char *)mempcpy(q, s - len, len);
*q++ = '"';
STADJUST(q - p, p);
@@ -2453,8 +2453,7 @@ path_advance(const char **path, const char *name)
growstackblock();
q = stackblock();
if (p != start) {
- memcpy(q, start, p - start);
- q += p - start;
+ q = mempcpy(q, start, p - start);
*q++ = '/';
}
strcpy(q, name);
@@ -5949,7 +5948,7 @@ rmescapes(char *str, int flag)
}
q = r;
if (len > 0) {
- q = (char *)memcpy(q, str, len) + len;
+ q = (char *)mempcpy(q, str, len);
}
}