From 4d788be80d98c792111f65605bb8853ab3cbdd4a Mon Sep 17 00:00:00 2001 From: Tomoki Aonuma Date: Mon, 13 Feb 2012 04:43:47 +0900 Subject: [PATCH] from_cstr and from_cstr_len are not unsafe, I think --- src/libcore/str.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 831a96962d41..5b4cc1f77e86 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -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); }