mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Move dummy url data to be a static member of URLExtraData.
This commit is contained in:
parent
3beaa8d2e9
commit
2820b7ac53
4 changed files with 7 additions and 14 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2787,12 +2787,10 @@ dependencies = [
|
||||||
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"geckoservo 0.0.1",
|
"geckoservo 0.0.1",
|
||||||
"lazy_static 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.18.0",
|
"selectors 0.18.0",
|
||||||
"servo_url 0.0.1",
|
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
|
@ -100,10 +100,10 @@ use super::stylesheet_loader::StylesheetLoader;
|
||||||
|
|
||||||
// A dummy url data for where we don't pass url data in.
|
// A dummy url data for where we don't pass url data in.
|
||||||
// We need to get rid of this sooner than later.
|
// We need to get rid of this sooner than later.
|
||||||
static mut DUMMY_URL_DATA: Option<*mut URLExtraData> = None;
|
static mut DUMMY_URL_DATA: *mut URLExtraData = 0 as *mut URLExtraData;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_Initialize() {
|
pub extern "C" fn Servo_Initialize(dummy_url_data: *mut URLExtraData) {
|
||||||
// Initialize logging.
|
// Initialize logging.
|
||||||
let mut builder = LogBuilder::new();
|
let mut builder = LogBuilder::new();
|
||||||
let default_level = if cfg!(debug_assertions) { "warn" } else { "error" };
|
let default_level = if cfg!(debug_assertions) { "warn" } else { "error" };
|
||||||
|
@ -122,9 +122,7 @@ pub extern "C" fn Servo_Initialize() {
|
||||||
gecko_properties::initialize();
|
gecko_properties::initialize();
|
||||||
|
|
||||||
// Initialize the dummy url data
|
// Initialize the dummy url data
|
||||||
unsafe {
|
unsafe { DUMMY_URL_DATA = dummy_url_data; }
|
||||||
DUMMY_URL_DATA = Some(bindings::Gecko_URLExtraData_CreateDummy());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -132,12 +130,13 @@ pub extern "C" fn Servo_Shutdown() {
|
||||||
// Clear some static data to avoid shutdown leaks.
|
// Clear some static data to avoid shutdown leaks.
|
||||||
gecko_properties::shutdown();
|
gecko_properties::shutdown();
|
||||||
|
|
||||||
// Clear the dummy url data to avoid shutdown leaks.
|
// The dummy url will be released after shutdown, so clear the
|
||||||
unsafe { RefPtr::from_addrefed(DUMMY_URL_DATA.take().unwrap()) };
|
// reference to avoid use-after-free.
|
||||||
|
unsafe { DUMMY_URL_DATA = ptr::null_mut(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> {
|
unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> {
|
||||||
RefPtr::from_ptr_ref(DUMMY_URL_DATA.as_ref().unwrap())
|
RefPtr::from_ptr_ref(&DUMMY_URL_DATA)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,
|
fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,
|
||||||
|
|
|
@ -19,12 +19,10 @@ atomic_refcell = "0.1"
|
||||||
cssparser = "0.12"
|
cssparser = "0.12"
|
||||||
env_logger = "0.4"
|
env_logger = "0.4"
|
||||||
euclid = "0.11"
|
euclid = "0.11"
|
||||||
lazy_static = "0.2"
|
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
||||||
parking_lot = "0.3"
|
parking_lot = "0.3"
|
||||||
selectors = {path = "../../../components/selectors"}
|
selectors = {path = "../../../components/selectors"}
|
||||||
servo_url = {path = "../../../components/url"}
|
|
||||||
style_traits = {path = "../../../components/style_traits"}
|
style_traits = {path = "../../../components/style_traits"}
|
||||||
geckoservo = {path = "../../../ports/geckolib"}
|
geckoservo = {path = "../../../ports/geckolib"}
|
||||||
style = {path = "../../../components/style", features = ["gecko"]}
|
style = {path = "../../../components/style", features = ["gecko"]}
|
||||||
|
|
|
@ -6,11 +6,9 @@ extern crate atomic_refcell;
|
||||||
extern crate cssparser;
|
extern crate cssparser;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate geckoservo;
|
extern crate geckoservo;
|
||||||
#[macro_use] extern crate lazy_static;
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
extern crate parking_lot;
|
extern crate parking_lot;
|
||||||
extern crate selectors;
|
extern crate selectors;
|
||||||
extern crate servo_url;
|
|
||||||
#[macro_use] extern crate style;
|
#[macro_use] extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue