Mercurial > hg > octave-kai > gnulib-hg
annotate lib/memmove.c @ 1710:a6e95d15d8fb
Include stdio.h.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Mon, 08 Feb 1999 03:32:06 +0000 |
parents | f07402a43c74 |
children | 42147e1c0cee |
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 | |
744 | 6 #if HAVE_CONFIG_H |
648 | 7 # include <config.h> |
443 | 8 #endif |
9 | |
643 | 10 void * |
386 | 11 memmove (dest, source, length) |
395 | 12 char *dest; |
13 const char *source; | |
386 | 14 unsigned length; |
15 { | |
654
6470fee04491
Oops. Always return destination.
Jim Meyering <jim@meyering.net>
parents:
648
diff
changeset
|
16 char *d0 = dest; |
386 | 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) | |
643 | 22 { |
23 /* Moving from hi mem to low mem; start at beginning. */ | |
24 for (; length; --length) | |
25 *dest++ = *source++; | |
26 } | |
654
6470fee04491
Oops. Always return destination.
Jim Meyering <jim@meyering.net>
parents:
648
diff
changeset
|
27 return (void *) d0; |
386 | 28 } |