]>
Commit | Line | Data |
---|---|---|
6599da04 JM |
1 | /* bcopy -- copy memory regions of arbitary length |
2 | ||
aaa5f039 | 3 | @deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length}) |
6599da04 | 4 | |
aaa5f039 DD |
5 | Copies @var{length} bytes from memory region @var{in} to region |
6 | @var{out}. The use of @code{bcopy} is deprecated in new programs. | |
6599da04 | 7 | |
aaa5f039 | 8 | @end deftypefn |
6599da04 JM |
9 | |
10 | */ | |
11 | ||
29138797 KG |
12 | #include <stddef.h> |
13 | ||
6599da04 | 14 | void |
29138797 | 15 | bcopy (const void *src, void *dest, size_t len) |
6599da04 JM |
16 | { |
17 | if (dest < src) | |
29138797 | 18 | { |
7445de0a DS |
19 | const char *firsts = (const char *) src; |
20 | char *firstd = (char *) dest; | |
29138797 KG |
21 | while (len--) |
22 | *firstd++ = *firsts++; | |
23 | } | |
6599da04 JM |
24 | else |
25 | { | |
29138797 KG |
26 | const char *lasts = (const char *)src + (len-1); |
27 | char *lastd = (char *)dest + (len-1); | |
6599da04 | 28 | while (len--) |
29138797 | 29 | *lastd-- = *lasts--; |
6599da04 JM |
30 | } |
31 | } |