mirror of
https://github.com/cahirwpz/libnix.git
synced 2026-01-12 07:36:21 +00:00
Allow for overlapping regions.
This commit is contained in:
@ -5,8 +5,17 @@ void bcopy(const void *s1,void *s2,size_t n)
|
||||
{
|
||||
unsigned char *ch1 = s1;
|
||||
unsigned char *ch2 = s2;
|
||||
while (n > 0) {
|
||||
*ch2++ = *ch1++;
|
||||
n--;
|
||||
if (ch1 < ch2) {
|
||||
while (n > 0) {
|
||||
*ch2++ = *ch1++;
|
||||
n--;
|
||||
}
|
||||
} else {
|
||||
ch1 += n;
|
||||
ch2 += n;
|
||||
while (n > 0) {
|
||||
*ch2-- = *ch1--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user