diff options
author | Jim Meyering <jim@meyering.net> | 1995-07-30 05:30:04 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1995-07-30 05:30:04 +0000 |
commit | 4aa1e2f2e890cbd11a0b681ccdc79aa08b53459e (patch) | |
tree | 59f08554ee39eb307790f90be2152b20374c7ed8 /lib | |
parent | ea4cda6907ed995c2ff2d4bd59d0c6162767f024 (diff) | |
download | coreutils-4aa1e2f2e890cbd11a0b681ccdc79aa08b53459e.tar.xz |
Get new copy from FSF.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/memcpy.c | 33 |
1 files changed, 12 insertions, 21 deletions
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 <assert.h> -#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; } |