Skip to content

Commit

Permalink
core::str::from_cstr uses from_cstr_len
Browse files Browse the repository at this point in the history
  • Loading branch information
uasi committed Feb 13, 2012
1 parent e5cc919 commit 8d29e87
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/libcore/str.rs
Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit 8d29e87

Please sign in to comment.