1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-19 18:26:32 +02:00
Files
coreutils/lib/memmove.c

25 lines
634 B
C
Raw Normal View History

1995-01-27 19:32:16 +00:00
/* 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>. */
1995-05-21 11:44:22 +00:00
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
1995-01-27 19:32:16 +00:00
void
memmove (dest, source, length)
1995-03-12 15:26:36 +00:00
char *dest;
const char *source;
1995-01-27 19:32:16 +00:00
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++;
}