NEWS.stable: log cherry-pick [8b18afa]->[c948e19] sys_select: Avoid a syntax error...
[gnulib.git] / lib / bcopy.c
1 /* bcopy.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>.  */
5
6 #include <stddef.h>
7
8 void
9 bcopy (void const *source0, void *dest0, size_t length)
10 {
11   char const *source = source0;
12   char *dest = dest0;
13   if (source < dest)
14     /* Moving from low mem to hi mem; start at end.  */
15     for (source += length, dest += length; length; --length)
16       *--dest = *--source;
17   else if (source != dest)
18     /* Moving from hi mem to low mem; start at beginning.  */
19     for (; length; --length)
20       *dest++ = *source++;
21 }