From cb715fe584f28fda2412132b9e2e79c0b0641ada Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 12 Mar 1995 18:21:38 +0000 Subject: . --- lib/memcpy.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/memcpy.c (limited to 'lib') 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 +#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++; +} -- cgit v1.2.3-54-g00ecf