*** empty log message ***
[libtasn1.git] / gl / memmove.c
blob753c899d387adf0177cb0cba0f5ef0f43e6ff759
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 #ifdef HAVE_CONFIG_H
7 # include <config.h>
8 #endif
10 #include <stddef.h>
12 void *
13 memmove (void *dest0, void const *source0, size_t length)
15 char *dest = dest0;
16 char const *source = source0;
17 if (source < dest)
18 /* Moving from low mem to hi mem; start at end. */
19 for (source += length, dest += length; length; --length)
20 *--dest = *--source;
21 else if (source != dest)
23 /* Moving from hi mem to low mem; start at beginning. */
24 for (; length; --length)
25 *dest++ = *source++;
27 return dest0;