# HG changeset patch # User Jim Meyering # Date 807082204 0 # Node ID 1da40035bfa27ed6b85506b45e6b64c037078d2a # Parent 675e697efedaf484c7ce0b64150575900d2bda6d Get new copy from FSF. diff --git a/lib/memcpy.c b/lib/memcpy.c --- a/lib/memcpy.c +++ b/lib/memcpy.c @@ -1,25 +1,16 @@ -/* 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 +/* Copy LEN bytes starting at SRCADDR to DESTADDR. Result undefined + if the source overlaps with the destination. + Return DESTADDR. */ -void -memcpy (dest, source, length) - char *dest; - const char *source; - unsigned length; +char * +memcpy (destaddr, srcaddr, len) + char *destaddr; + const char *srcaddr; + int len; { - assert (length >= 0); - /* Make sure they don't overlap. */ - assert (ABS (dest - source) >= length); + char *dest = destaddr; - for (; length; --length) - *dest++ = *source++; + while (len-- > 0) + *destaddr++ = *srcaddr++; + return dest; }