mirror of
https://github.com/servo/servo.git
synced 2025-08-18 03:45:33 +01:00
embedding: remove eutil::fptr_is_null, fix #3967, add Option<> to fptrs
This commit is contained in:
parent
85a2f0b66a
commit
d33f74f499
7 changed files with 213 additions and 222 deletions
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
use eutil::{fptr_is_null, slice_to_str};
|
||||
use eutil::slice_to_str;
|
||||
use libc::{size_t, c_int, c_ushort,c_void};
|
||||
use libc::types::os::arch::c95::wchar_t;
|
||||
use mem::{new0,newarray0,delete,deletearray};
|
||||
|
@ -52,8 +52,8 @@ pub extern "C" fn cef_string_userfree_utf16_free(cs: *mut cef_string_userfree_ut
|
|||
#[no_mangle]
|
||||
pub extern "C" fn cef_string_utf8_clear(cs: *mut cef_string_utf8_t) {
|
||||
unsafe {
|
||||
if !fptr_is_null(mem::transmute((*cs).dtor)) {
|
||||
let dtor = (*cs).dtor;
|
||||
if (*cs).dtor.is_some() {
|
||||
let dtor = (*cs).dtor.unwrap();
|
||||
dtor((*cs).str);
|
||||
}
|
||||
(*cs).length = 0;
|
||||
|
@ -81,7 +81,7 @@ pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: *
|
|||
|
||||
ptr::copy_memory((*output).str, src, src_len as uint);
|
||||
(*output).length = src_len;
|
||||
(*output).dtor = string_utf8_dtor;
|
||||
(*output).dtor = Some(string_utf8_dtor);
|
||||
}
|
||||
} else {
|
||||
(*output).str = mem::transmute(src);
|
||||
|
@ -134,8 +134,8 @@ pub extern "C" fn cef_string_utf16_to_utf8(src: *const u16, src_len: size_t, out
|
|||
#[no_mangle]
|
||||
pub extern "C" fn cef_string_utf16_clear(cs: *mut cef_string_utf16_t) {
|
||||
unsafe {
|
||||
if !fptr_is_null(mem::transmute((*cs).dtor)) {
|
||||
let dtor = (*cs).dtor;
|
||||
if (*cs).dtor.is_some() {
|
||||
let dtor = (*cs).dtor.unwrap();
|
||||
dtor((*cs).str);
|
||||
}
|
||||
(*cs).length = 0;
|
||||
|
@ -163,7 +163,7 @@ pub extern "C" fn cef_string_utf16_set(src: *const c_ushort, src_len: size_t, ou
|
|||
|
||||
ptr::copy_memory((*output).str, src, src_len as uint);
|
||||
(*output).length = src_len;
|
||||
(*output).dtor = string_utf16_dtor;
|
||||
(*output).dtor = Some(string_utf16_dtor);
|
||||
}
|
||||
} else {
|
||||
(*output).str = mem::transmute(src);
|
||||
|
@ -192,8 +192,8 @@ pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const c
|
|||
#[no_mangle]
|
||||
pub extern "C" fn cef_string_wide_clear(cs: *mut cef_string_wide_t) {
|
||||
unsafe {
|
||||
if !fptr_is_null(mem::transmute((*cs).dtor)) {
|
||||
let dtor = (*cs).dtor;
|
||||
if (*cs).dtor.is_some() {
|
||||
let dtor = (*cs).dtor.unwrap();
|
||||
dtor((*cs).str);
|
||||
}
|
||||
(*cs).length = 0;
|
||||
|
@ -221,7 +221,7 @@ pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, outp
|
|||
|
||||
ptr::copy_memory((*output).str, src, src_len as uint);
|
||||
(*output).length = src_len;
|
||||
(*output).dtor = string_wide_dtor;
|
||||
(*output).dtor = Some(string_wide_dtor);
|
||||
}
|
||||
} else {
|
||||
(*output).str = mem::transmute(src);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue