Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / texinfo / lib / memmove.c
blob5519fe761df4dde083cfa101b517745a7f6c2978
1 /* $NetBSD$ */
3 /* memmove.c -- copy memory.
4 Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate.
5 In the public domain.
6 By David MacKenzie <djm@gnu.ai.mit.edu>. */
8 #if HAVE_CONFIG_H
9 # include <config.h>
10 #endif
12 #include <stddef.h>
14 void *
15 memmove (void *dest0, void const *source0, size_t length)
17 char *dest = dest0;
18 char const *source = source0;
19 if (source < dest)
20 /* Moving from low mem to hi mem; start at end. */
21 for (source += length, dest += length; length; --length)
22 *--dest = *--source;
23 else if (source != dest)
25 /* Moving from hi mem to low mem; start at beginning. */
26 for (; length; --length)
27 *dest++ = *source++;
29 return dest0;