mirror of
https://github.com/cahirwpz/libnix.git
synced 2026-09-11 19:26:17 +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 *ch1 = s1;
|
||||||
unsigned char *ch2 = s2;
|
unsigned char *ch2 = s2;
|
||||||
while (n > 0) {
|
if (ch1 < ch2) {
|
||||||
*ch2++ = *ch1++;
|
while (n > 0) {
|
||||||
n--;
|
*ch2++ = *ch1++;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ch1 += n;
|
||||||
|
ch2 += n;
|
||||||
|
while (n > 0) {
|
||||||
|
*ch2-- = *ch1--;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user