X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fmemcpy.c;h=dba7d56f125b92278581863119369de9d72185f5;hb=7bfecbc4117c0917eaea6d4a8b6dad4db78982f1;hp=a1f8b8f2b5e9711d16ded023612302fd3fd5ae8f;hpb=512ba8f4f8cd29b154fc3ddf064276f0db9fd294;p=gnulib.git diff --git a/lib/memcpy.c b/lib/memcpy.c index a1f8b8f2b..dba7d56f1 100644 --- 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. */ +/* Copy LEN bytes starting at SRCADDR to DESTADDR. Result undefined + if the source overlaps with the destination. + Return DESTADDR. */ -/* 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; +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; }