string: implement strcat, strcmp, strcpy, and strdup

This commit is contained in:
Alex Lyon
2018-03-07 14:06:30 -08:00
parent 114ee16c21
commit 9f39456dbd
4 changed files with 27 additions and 19 deletions
+2 -11
View File
@@ -32,18 +32,9 @@ use types::*;
pub static mut errno: c_int = 0;
pub unsafe fn c_str(s: *const c_char) -> &'static [u8] {
use core::slice;
use core::usize;
let mut size = 0;
loop {
if *s.offset(size) == 0 {
break;
}
size += 1;
}
slice::from_raw_parts(s as *const u8, size as usize)
c_str_n(s, usize::MAX)
}
pub unsafe fn c_str_n(s: *const c_char, n: usize) -> &'static [u8] {