Remove no-op string_list_to_vec function.

This commit is contained in:
Ms2ger 2015-06-20 13:39:05 +02:00
parent 2248e1710a
commit 4a7c5c8042

View file

@ -11,10 +11,6 @@ use types::{cef_string_list_t,cef_string_t};
use rustc_unicode::str::Utf16Encoder;
fn string_list_to_vec(lt: *mut cef_string_list_t) -> *mut Vec<String> {
lt as *mut Vec<String>
}
//cef_string_list
#[no_mangle]
@ -26,8 +22,7 @@ pub extern "C" fn cef_string_list_alloc() -> *mut cef_string_list_t {
pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int {
unsafe {
if lt.is_null() { return 0; }
let v = string_list_to_vec(lt);
(*v).len() as c_int
(*lt).len() as c_int
}
}
@ -35,8 +30,7 @@ pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int {
pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *const cef_string_t) {
unsafe {
if lt.is_null() { return; }
let v = string_list_to_vec(lt);
(*v).push(String::from_utf16(slice::from_raw_parts((*value).str, (*value).length as usize)).unwrap());
(*lt).push(String::from_utf16(slice::from_raw_parts((*value).str, (*value).length as usize)).unwrap());
}
}
@ -44,9 +38,8 @@ pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *con
pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int, value: *mut cef_string_t) -> c_int {
unsafe {
if index < 0 || lt.is_null() { return 0; }
let v = string_list_to_vec(lt);
if index as usize > (*v).len() - 1 { return 0; }
let ref string = (*v)[index as usize];
if index as usize > (*lt).len() - 1 { return 0; }
let ref string = (*lt)[index as usize];
let utf16_chars: Vec<u16> = Utf16Encoder::new(string.chars()).collect();
cef_string_utf16_set(mem::transmute(utf16_chars.as_ptr()), utf16_chars.len() as u64, value, 1)
}
@ -56,8 +49,7 @@ pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int
pub extern "C" fn cef_string_list_clear(lt: *mut cef_string_list_t) {
unsafe {
if lt.is_null() { return; }
let v = string_list_to_vec(lt);
(*v).clear();
(*lt).clear();
}
}
@ -74,8 +66,7 @@ pub extern "C" fn cef_string_list_free(lt: *mut cef_string_list_t) {
pub extern "C" fn cef_string_list_copy(lt: *mut cef_string_list_t) -> *mut cef_string_list_t {
unsafe {
if lt.is_null() { return 0 as *mut cef_string_list_t; }
let v = string_list_to_vec(lt);
let copy = (*v).clone();
let copy = (*lt).clone();
boxed::into_raw(box copy)
}
}