summaryrefslogtreecommitdiff
path: root/lib/memcpy.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-03-12 18:21:38 +0000
committerJim Meyering <jim@meyering.net>1995-03-12 18:21:38 +0000
commitcb715fe584f28fda2412132b9e2e79c0b0641ada (patch)
treec909c883b1a9d07b3b0999af253ba05f26b85833 /lib/memcpy.c
parent858157b65bb62f4a26d6d82c4e8db66c586d1cc7 (diff)
downloadcoreutils-cb715fe584f28fda2412132b9e2e79c0b0641ada.tar.xz
.
Diffstat (limited to 'lib/memcpy.c')
-rw-r--r--lib/memcpy.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/memcpy.c b/lib/memcpy.c
new file mode 100644
index 000000000..a1f8b8f2b
--- /dev/null
+++ b/lib/memcpy.c
@@ -0,0 +1,25 @@
+/* memcpy.c -- copy memory.
+ Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate.
+ The source and destination regions may not overlap.
+ In the public domain.
+ By Jim Meyering. */
+
+/* FIXME: remove this before release. */
+#include <assert.h>
+#ifndef ABS
+# define ABS(x) ((x) < 0 ? (-(x)) : (x))
+#endif
+
+void
+memcpy (dest, source, length)
+ char *dest;
+ const char *source;
+ unsigned length;
+{
+ assert (length >= 0);
+ /* Make sure they don't overlap. */
+ assert (ABS (dest - source) >= length);
+
+ for (; length; --length)
+ *dest++ = *source++;
+}