You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
694 B

/* bcopy -- copy memory regions of arbitary length
25 years ago
@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
25 years ago
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. The use of @code{bcopy} is deprecated in new programs.
25 years ago
@end deftypefn
*/
22 years ago
#include <stddef.h>
void
22 years ago
bcopy (const void *src, void *dest, size_t len)
{
if (dest < src)
22 years ago
{
20 years ago
const char *firsts = (const char *) src;
char *firstd = (char *) dest;
22 years ago
while (len--)
*firstd++ = *firsts++;
}
else
{
22 years ago
const char *lasts = (const char *)src + (len-1);
char *lastd = (char *)dest + (len-1);
while (len--)
22 years ago
*lastd-- = *lasts--;
}
}