diff options
Diffstat (limited to 'src/string/memcpy.c')
-rw-r--r-- | src/string/memcpy.c | 31 |
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) +*/ |