1
Fork 0

core::str::from_cstr uses from_cstr_len

This commit is contained in:
Tomoki Aonuma 2012-02-13 04:42:10 +09:00
parent e5cc9193f8
commit 8d29e87056

View file

@ -195,16 +195,14 @@ Function: from_cstr
Create a Rust string from a null-terminated C string
*/
unsafe fn from_cstr(cstr: sbuf) -> str {
let res = [];
let start = cstr;
let curr = start;
let i = 0u;
while *curr != 0u8 {
vec::push(res, *curr);
i += 1u;
curr = ptr::offset(start, i);
}
ret from_bytes(res);
ret from_cstr_len(cstr, i);
}
/*