Fix some warnings in the CEF port.

This commit is contained in:
Ms2ger 2015-03-23 00:35:23 +01:00
parent 445f1c891a
commit b45cf4ccf8
5 changed files with 10 additions and 11 deletions

View file

@ -18,9 +18,9 @@ use libc::c_int;
use util::opts; use util::opts;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::cell::{Cell, RefCell, BorrowState}; use std::cell::{Cell, RefCell, BorrowState};
use std::sync::atomic::{AtomicInt, Ordering}; use std::sync::atomic::{AtomicIsize, Ordering};
thread_local!(pub static ID_COUNTER: AtomicInt = AtomicInt::new(0)); thread_local!(pub static ID_COUNTER: AtomicIsize = AtomicIsize::new(0));
thread_local!(pub static BROWSERS: RefCell<Vec<CefBrowser>> = RefCell::new(vec!())); thread_local!(pub static BROWSERS: RefCell<Vec<CefBrowser>> = RefCell::new(vec!()));
pub enum ServoBrowser { pub enum ServoBrowser {

View file

@ -34,9 +34,8 @@ pub fn command_line_init(argc: c_int, argv: *const *const u8) {
unsafe { unsafe {
let mut a: Vec<String> = vec!(); let mut a: Vec<String> = vec!();
for i in 0u..(argc as uint) { for i in 0u..(argc as uint) {
let offset = *argv.offset(i as int) as *const c_char; let slice = ffi::CStr::from_ptr(*argv.offset(i as int) as *const c_char);
let slice = ffi::c_str_to_bytes(&offset); let s = str::from_utf8(slice.to_bytes()).unwrap();
let s = str::from_utf8(slice).unwrap();
a.push(String::from_str(s)); a.push(String::from_str(s));
} }
let cl = command_line_new(); let cl = command_line_new();

View file

@ -128,8 +128,8 @@ pub extern "C" fn cef_log(_file: *const c_char,
_severity: c_int, _severity: c_int,
message: *const c_char) { message: *const c_char) {
unsafe { unsafe {
let slice = ffi::c_str_to_bytes(&message); let slice = ffi::CStr::from_ptr(message);
println!("{}", str::from_utf8(slice).unwrap()) println!("{}", str::from_utf8(slice.to_bytes()).unwrap())
} }
} }

View file

@ -94,7 +94,7 @@ pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: *
return 0; return 0;
} }
ptr::copy_memory((*output).str, src, src_len as uint); ptr::copy((*output).str, src, src_len as uint);
(*output).length = src_len; (*output).length = src_len;
(*output).dtor = Some(string_utf8_dtor as extern "C" fn(*mut u8)); (*output).dtor = Some(string_utf8_dtor as extern "C" fn(*mut u8));
} }
@ -175,7 +175,7 @@ pub extern "C" fn cef_string_utf16_set(src: *const c_ushort, src_len: size_t, ou
return 0; return 0;
} }
ptr::copy_memory((*output).str, src, src_len as uint); ptr::copy((*output).str, src, src_len as uint);
(*output).length = src_len; (*output).length = src_len;
(*output).dtor = Some(string_utf16_dtor as extern "C" fn(*mut c_ushort)); (*output).dtor = Some(string_utf16_dtor as extern "C" fn(*mut c_ushort));
} }
@ -233,7 +233,7 @@ pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, outp
return 0; return 0;
} }
ptr::copy_memory((*output).str, src, src_len as uint); ptr::copy((*output).str, src, src_len as uint);
(*output).length = src_len; (*output).length = src_len;
(*output).dtor = Some(string_wide_dtor as extern "C" fn(*mut wchar_t)); (*output).dtor = Some(string_wide_dtor as extern "C" fn(*mut wchar_t));
} }

View file

@ -182,7 +182,7 @@ impl<'a> CefWrap<*const cef_string_t> for &'a [u16] {
fn to_c(buffer: &'a [u16]) -> *const cef_string_t { fn to_c(buffer: &'a [u16]) -> *const cef_string_t {
unsafe { unsafe {
let ptr: *mut c_ushort = mem::transmute(libc::malloc(((buffer.len() + 1) * 2) as u64)); let ptr: *mut c_ushort = mem::transmute(libc::malloc(((buffer.len() + 1) * 2) as u64));
ptr::copy_memory(ptr, mem::transmute(buffer.as_ptr()), buffer.len()); ptr::copy(ptr, mem::transmute(buffer.as_ptr()), buffer.len());
*ptr.offset(buffer.len() as int) = 0; *ptr.offset(buffer.len() as int) = 0;
// FIXME(pcwalton): This leaks!! We should instead have the caller pass some scratch // FIXME(pcwalton): This leaks!! We should instead have the caller pass some scratch