[hackers] [scc] [libc] Add memmove() || Roberto E. Vargas Caballero
commit 4b31904c19ede644b5657f46b5823faf9e2bcf09
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Feb 17 08:31:48 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Feb 17 08:31:48 2017 +0100
[libc] Add memmove()
diff --git a/libc/src/Makefile b/libc/src/Makefile
index 0e0d23e..6f54f53 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
_AT_@ -3,7 +3,7 @@
LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
strrchr.o strcat.o strncpy.o strncat.o \
- memset.o memcpy.o
+ memset.o memcpy.o memmove.o
all: libc.a
diff --git a/libc/src/memmove.c b/libc/src/memmove.c
new file mode 100644
index 0000000..c76006a
--- /dev/null
+++ b/libc/src/memmove.c
_AT_@ -0,0 +1,19 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+void *
+memmove(void *dst, const void *src, size_t n)
+{
+ char *d = dst, *s = (char *) src;
+
+ if (d < s) {
+ while (n-- > 0)
+ *d++ = *s++;
+ } else {
+ s += n-1, d += n-1;
+ while (n-- > 0)
+ *d-- = *s--;
+ }
+ return dst;
+}
Received on Fri Feb 17 2017 - 08:47:29 CET
This archive was generated by hypermail 2.3.0
: Fri Feb 17 2017 - 08:48:19 CET