Mercurial > hg > octave-lyh > gnulib-hg
changeset 397:2a84024fa38d
.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Sun, 12 Mar 1995 18:21:38 +0000 |
parents | 98a444435129 |
children | f016816dffa3 |
files | lib/memcpy.c |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /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 <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++; +}