Merge branch 'whiletofor' into 'master'

Changed while loops to for

See merge request redox-os/relibc!206
This commit is contained in:
jD91mZM2
2019-04-21 15:04:10 +00:00
2 changed files with 6 additions and 18 deletions
+2 -6
View File
@@ -139,10 +139,8 @@ pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: size_t)
#[no_mangle]
pub unsafe extern "C" fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void {
let mut i = 0;
while i < n {
for i in 0..n {
*(s as *mut u8).add(i) = c as u8;
i += 1;
}
s
}
@@ -235,10 +233,8 @@ pub unsafe extern "C" fn strndup(s1: *const c_char, size: size_t) -> *mut c_char
platform::errno = ENOMEM as c_int;
} else {
//memcpy(buffer, s1, len)
let mut i = 0;
while i < len {
for i in 0..len {
*buffer.add(i) = *s1.add(i);
i += 1;
}
*buffer.add(len) = 0;
}
+4 -12
View File
@@ -389,8 +389,7 @@ pub unsafe extern "C" fn wcsncat(
#[no_mangle]
pub unsafe extern "C" fn wcsncmp(ws1: *const wchar_t, ws2: *const wchar_t, n: size_t) -> c_int {
let mut i = 0;
while i < n {
for i in 0..n {
let wc1 = *ws1.add(i);
let wc2 = *ws2.add(i);
if wc1 != wc2 {
@@ -398,7 +397,6 @@ pub unsafe extern "C" fn wcsncmp(ws1: *const wchar_t, ws2: *const wchar_t, n: si
} else if wc1 == 0 {
break;
}
i += 1;
}
0
}
@@ -520,26 +518,22 @@ pub extern "C" fn wcwidth(wc: wchar_t) -> c_int {
#[no_mangle]
pub unsafe extern "C" fn wmemchr(ws: *const wchar_t, wc: wchar_t, n: size_t) -> *mut wchar_t {
let mut i = 0;
while i < n {
for i in 0..n {
if *ws.add(i) == wc {
return ws.add(i) as *mut wchar_t;
}
i += 1;
}
0 as *mut wchar_t
}
#[no_mangle]
pub unsafe extern "C" fn wmemcmp(ws1: *const wchar_t, ws2: *const wchar_t, n: size_t) -> c_int {
let mut i = 0;
while i < n {
for i in 0..n {
let wc1 = *ws1.add(i);
let wc2 = *ws2.add(i);
if wc1 != wc2 {
return wc1 - wc2;
}
i += 1;
}
0
}
@@ -572,10 +566,8 @@ pub unsafe extern "C" fn wmemmove(
#[no_mangle]
pub unsafe extern "C" fn wmemset(ws: *mut wchar_t, wc: wchar_t, n: size_t) -> *mut wchar_t {
let mut i = 0;
while i < n {
for i in 0..n {
*ws.add(i) = wc;
i += 1;
}
ws
}