bfd/
[binutils.git] / libiberty / bcopy.c
blobf9b7a8acd5c72bbd870789f44124135bad5a06ab
1 /* bcopy -- copy memory regions of arbitary length
3 @deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
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.
8 @end deftypefn
12 #include <stddef.h>
14 void
15 bcopy (const void *src, void *dest, size_t len)
17 if (dest < src)
19 const char *firsts = (const char *) src;
20 char *firstd = (char *) dest;
21 while (len--)
22 *firstd++ = *firsts++;
24 else
26 const char *lasts = (const char *)src + (len-1);
27 char *lastd = (char *)dest + (len-1);
28 while (len--)
29 *lastd-- = *lasts--;