Mercurial > hg > octave-kai > gnulib-hg
changeset 386:039a69330b88
.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Fri, 27 Jan 1995 19:32:16 +0000 |
parents | f4cb6bbc01d4 |
children | cba837b4fd06 |
files | lib/memmove.c |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/lib/memmove.c @@ -0,0 +1,19 @@ +/* memmove.c -- copy memory. + Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate. + In the public domain. + By David MacKenzie <djm@gnu.ai.mit.edu>. */ + +void +memmove (dest, source, length) + char *dest, *source; + unsigned length; +{ + if (source < dest) + /* Moving from low mem to hi mem; start at end. */ + for (source += length, dest += length; length; --length) + *--dest = *--source; + else if (source != dest) + /* Moving from hi mem to low mem; start at beginning. */ + for (; length; --length) + *dest++ = *source++; +}