[PATCH] lib: string: implement mempcpy
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Oct 31 23:43:10 PDT 2022
mempcpy(3) is a GNU libc extension that like stpcpy returns not the
start of the destination buffer, but the first byte after its end.
Provide it as it is useful when concatenating buffers or known-size
strings.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
v1 -> v2:
- split off function from series using it. Other series needs
commits reordered.
---
include/string.h | 1 +
lib/string.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/include/string.h b/include/string.h
index 2cc727fd1d7a..596440ca8164 100644
--- a/include/string.h
+++ b/include/string.h
@@ -4,6 +4,7 @@
#include <linux/string.h>
+void *mempcpy(void *dest, const void *src, size_t count);
int strtobool(const char *str, int *val);
char *strsep_unescaped(char **, const char *);
char *stpcpy(char *dest, const char *src);
diff --git a/lib/string.c b/lib/string.c
index fd4d7da10a7c..edd36da4d4f2 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -603,6 +603,11 @@ void *__memcpy(void * dest, const void *src, size_t count)
__alias(__default_memcpy);
#endif
+void *mempcpy(void *dest, const void *src, size_t count)
+{
+ return memcpy(dest, src, count) + count;
+}
+EXPORT_SYMBOL(mempcpy);
#ifndef __HAVE_ARCH_MEMMOVE
/**
--
2.30.2
More information about the barebox
mailing list