summaryrefslogtreecommitdiff
path: root/src/string/memcpy.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-08 18:42:39 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-08 18:42:39 -0500
commit7ef8a7379f7f7d09e71ccae2a0b688c3cd80423f (patch)
tree092ab0aed1769117fd7b28b8592f6f96b0e0d5af /src/string/memcpy.c
parent6acf19370e8adff79cd83b257d3f04aeaf2a59dd (diff)
merge sources into single tree
Diffstat (limited to 'src/string/memcpy.c')
-rw-r--r--src/string/memcpy.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/string/memcpy.c b/src/string/memcpy.c
new file mode 100644
index 00000000..f53fe5d8
--- /dev/null
+++ b/src/string/memcpy.c
@@ -0,0 +1,31 @@
+#include <string.h>
+#include "nonstd/assert.h"
+
+/** copy memory **/
+void * memcpy(void * restrict s1, const void * restrict s2, size_t n)
+{
+ char *dst = (char*)s1;
+ char *src = (char*)s2;
+ size_t i = 0;
+
+ ASSERT_NONNULL(s1);
+ ASSERT_NONNULL(s2);
+ ASSERT_NOOVERLAP(s1, s2, n);
+
+ for (i = 0; i < n; i++) {
+ dst[i] = src[i];
+ }
+
+ /*
+ RETURN_ALWAYS(ARGUMENT(s1));
+ */
+ return dst;
+}
+
+/***
+copies ARGUMENT(n) bytes from the object at ARGUMENT(s2) to the object at
+ARGUMENT(s1).
+***/
+/*
+STDC(1)
+*/