Mercurial > gnulib
annotate lib/memmove.c @ 40186:8964917f9574
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Mon, 18 Feb 2019 08:02:49 -0800 |
parents | e8d2c6fc33ad |
children |
rev | line source |
---|---|
386 | 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>. */ | |
5 | |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
6 #include <config.h> |
443 | 7 |
4664 | 8 #include <stddef.h> |
9 | |
643 | 10 void * |
4664 | 11 memmove (void *dest0, void const *source0, size_t length) |
386 | 12 { |
4664 | 13 char *dest = dest0; |
14 char const *source = source0; | |
386 | 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) | |
643 | 20 { |
21 /* Moving from hi mem to low mem; start at beginning. */ | |
22 for (; length; --length) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
23 *dest++ = *source++; |
643 | 24 } |
4664 | 25 return dest0; |
386 | 26 } |