mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:16:45 +01:00
from_cstr and from_cstr_len are not unsafe, I think
This commit is contained in:
parent
8d29e87056
commit
4d788be80d
@ -194,7 +194,7 @@ Function: from_cstr
|
||||
|
||||
Create a Rust string from a null-terminated C string
|
||||
*/
|
||||
unsafe fn from_cstr(cstr: sbuf) -> str {
|
||||
fn from_cstr(cstr: sbuf) -> str unsafe {
|
||||
let start = cstr;
|
||||
let curr = start;
|
||||
let i = 0u;
|
||||
@ -210,7 +210,7 @@ Function: from_cstr_len
|
||||
|
||||
Create a Rust string from a C string of the given length
|
||||
*/
|
||||
unsafe fn from_cstr_len(cstr: sbuf, len: uint) -> str {
|
||||
fn from_cstr_len(cstr: sbuf, len: uint) -> str unsafe {
|
||||
let buf: [u8] = [];
|
||||
vec::reserve(buf, len + 1u);
|
||||
vec::as_buf(buf) {|b| ptr::memcpy(b, cstr, len); }
|
||||
|
Loading…
Reference in New Issue
Block a user