| 1 | /* bcopy -- copy memory regions of arbitary length |
| 2 | |
| 3 | NAME |
| 4 | bcopy -- copy memory regions of arbitrary length |
| 5 | |
| 6 | SYNOPSIS |
| 7 | void bcopy (char *in, char *out, int length) |
| 8 | |
| 9 | DESCRIPTION |
| 10 | Copy LENGTH bytes from memory region pointed to by IN to memory |
| 11 | region pointed to by OUT. |
| 12 | |
| 13 | BUGS |
| 14 | Significant speed improvements can be made in some cases by |
| 15 | implementing copies of multiple bytes simultaneously, or unrolling |
| 16 | the copy loop. |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | void |
| 21 | bcopy (src, dest, len) |
| 22 | register char *src, *dest; |
| 23 | int len; |
| 24 | { |
| 25 | if (dest < src) |
| 26 | while (len--) |
| 27 | *dest++ = *src++; |
| 28 | else |
| 29 | { |
| 30 | char *lasts = src + (len-1); |
| 31 | char *lastd = dest + (len-1); |
| 32 | while (len--) |
| 33 | *(char *)lastd-- = *(char *)lasts--; |
| 34 | } |
| 35 | } |