Skip to content

Commit

Permalink
from_cstr and from_cstr_len are not unsafe, I think
Browse files Browse the repository at this point in the history
  • Loading branch information
uasi committed Feb 13, 2012
1 parent 8d29e87 commit 4d788be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libcore/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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); }
Expand Down

0 comments on commit 4d788be

Please sign in to comment.