Skip to content

Commit 4f206cf

Browse files
committed
std: str conversion fns should take *const u8
1 parent 24fe8bb commit 4f206cf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libstd/str.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -847,18 +847,18 @@ pub mod raw {
847847
use vec::MutableVector;
848848

849849
/// Create a Rust string from a null-terminated *u8 buffer
850-
pub unsafe fn from_buf(buf: *u8) -> ~str {
850+
pub unsafe fn from_buf(buf: *const u8) -> ~str {
851851
let mut curr = buf;
852852
let mut i = 0u;
853853
while *curr != 0u8 {
854854
i += 1u;
855-
curr = ptr::offset(buf, i);
855+
curr = ptr::const_offset(buf, i);
856856
}
857857
return from_buf_len(buf, i);
858858
}
859859

860860
/// Create a Rust string from a *u8 buffer of the given length
861-
pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str {
861+
pub unsafe fn from_buf_len(buf: *const u8, len: uint) -> ~str {
862862
let mut v: ~[u8] = vec::with_capacity(len + 1);
863863
v.as_mut_buf(|vbuf, _len| {
864864
ptr::copy_memory(vbuf, buf as *u8, len)
@@ -871,12 +871,12 @@ pub mod raw {
871871
}
872872

873873
/// Create a Rust string from a null-terminated C string
874-
pub unsafe fn from_c_str(c_str: *libc::c_char) -> ~str {
874+
pub unsafe fn from_c_str(c_str: *const libc::c_char) -> ~str {
875875
from_buf(::cast::transmute(c_str))
876876
}
877877

878878
/// Create a Rust string from a `*c_char` buffer of the given length
879-
pub unsafe fn from_c_str_len(c_str: *libc::c_char, len: uint) -> ~str {
879+
pub unsafe fn from_c_str_len(c_str: *const libc::c_char, len: uint) -> ~str {
880880
from_buf_len(::cast::transmute(c_str), len)
881881
}
882882

0 commit comments

Comments
 (0)