Update gnulib files, don't require LGPL modules (the libtasn1 library doesn't use...
[libtasn1.git] / gl / memmove.c
blobc5ff8b520df9802d0ada61ee5a940a73e8d35d0c
1 /* memmove.c -- copy memory.
2 Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate.
3 In the public domain.
4 By David MacKenzie <djm@gnu.ai.mit.edu>. */
6 #include <config.h>
8 #include <stddef.h>
10 void *
11 memmove (void *dest0, void const *source0, size_t length)
13 char *dest = dest0;
14 char const *source = source0;
15 if (source < dest)
16 /* Moving from low mem to hi mem; start at end. */
17 for (source += length, dest += length; length; --length)
18 *--dest = *--source;
19 else if (source != dest)
21 /* Moving from hi mem to low mem; start at beginning. */
22 for (; length; --length)
23 *dest++ = *source++;
25 return dest0;