core::str::from_cstr uses from_cstr_len
This commit is contained in:
parent
e5cc9193f8
commit
8d29e87056
1 changed files with 1 additions and 3 deletions
|
@ -195,16 +195,14 @@ Function: from_cstr
|
||||||
Create a Rust string from a null-terminated C string
|
Create a Rust string from a null-terminated C string
|
||||||
*/
|
*/
|
||||||
unsafe fn from_cstr(cstr: sbuf) -> str {
|
unsafe fn from_cstr(cstr: sbuf) -> str {
|
||||||
let res = [];
|
|
||||||
let start = cstr;
|
let start = cstr;
|
||||||
let curr = start;
|
let curr = start;
|
||||||
let i = 0u;
|
let i = 0u;
|
||||||
while *curr != 0u8 {
|
while *curr != 0u8 {
|
||||||
vec::push(res, *curr);
|
|
||||||
i += 1u;
|
i += 1u;
|
||||||
curr = ptr::offset(start, i);
|
curr = ptr::offset(start, i);
|
||||||
}
|
}
|
||||||
ret from_bytes(res);
|
ret from_cstr_len(cstr, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue