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>. */
|
|
|
|
|
|
1996-10-17 03:05:09 +00:00
|
|
|
#if HAVE_CONFIG_H
|
1996-07-15 02:29:59 +00:00
|
|
|
# include <config.h>
|
1995-05-21 11:44:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
1996-07-14 15:05:40 +00:00
|
|
|
void *
|
1995-01-27 19:32:16 +00:00
|
|
|
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;
|
|
|
|
|
{
|
1996-07-16 03:06:32 +00:00
|
|
|
char *d0 = dest;
|
1995-01-27 19:32:16 +00:00
|
|
|
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)
|
1996-07-14 15:05:40 +00:00
|
|
|
{
|
|
|
|
|
/* Moving from hi mem to low mem; start at beginning. */
|
|
|
|
|
for (; length; --length)
|
|
|
|
|
*dest++ = *source++;
|
|
|
|
|
}
|
1996-07-16 03:06:32 +00:00
|
|
|
return (void *) d0;
|
1995-01-27 19:32:16 +00:00
|
|
|
}
|