diff lib/memcpy.c @ 280:2b8b9312ed33

GNU text utilities
author Jim Meyering <jim@meyering.net>
date Tue, 21 Mar 1995 03:48:38 +0000
parents
children 1da40035bfa2
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/memcpy.c	Tue Mar 21 03:48:38 1995 +0000
@@ -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++;
+}