mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-12 06:53:05 +00:00
std: fix a bad type cast for in str.to_c_str()
This commit is contained in:
parent
72688eaa13
commit
aababbba8e
@ -124,7 +124,7 @@ impl<'self> ToCStr for &'self [u8] {
|
|||||||
fn to_c_str(&self) -> CString {
|
fn to_c_str(&self) -> CString {
|
||||||
do self.as_imm_buf |self_buf, self_len| {
|
do self.as_imm_buf |self_buf, self_len| {
|
||||||
unsafe {
|
unsafe {
|
||||||
let buf = libc::malloc(self_len as u64 + 1) as *mut u8;
|
let buf = libc::malloc(self_len as libc::size_t + 1) as *mut u8;
|
||||||
if buf.is_null() {
|
if buf.is_null() {
|
||||||
fail!("failed to allocate memory!");
|
fail!("failed to allocate memory!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user