string: add strnlen_s()

This commit is contained in:
Alex Lyon
2019-04-26 20:32:44 -07:00
parent 67af78d0eb
commit 5bbce37789
4 changed files with 91 additions and 0 deletions
+9
View File
@@ -263,6 +263,15 @@ pub unsafe extern "C" fn strnlen(s: *const c_char, size: size_t) -> size_t {
i as size_t
}
#[no_mangle]
pub unsafe extern "C" fn strnlen_s(s: *const c_char, size: size_t) -> size_t {
if s.is_null() {
0
} else {
strnlen(s, size)
}
}
#[no_mangle]
pub unsafe extern "C" fn strcat(s1: *mut c_char, s2: *const c_char) -> *mut c_char {
strncat(s1, s2, usize::MAX)