aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/utils.rs
diff options
context:
space:
mode:
authorTim Cuthbertson <tim@gfxmonk.net>2015-03-20 11:28:04 +1100
committerTim Cuthbertson <tim@gfxmonk.net>2015-03-20 22:14:14 +1100
commit0052a27b1a1882a6b67f2f424d90a0b325480872 (patch)
tree203e1a82af1c6435c3dbc4656f67383c6ee5559f /components/script/dom/bindings/utils.rs
parentdea36f981650f027902b4f71f0cdabd2da69fe21 (diff)
downloadservo-0052a27b1a1882a6b67f2f424d90a0b325480872.tar.gz
servo-0052a27b1a1882a6b67f2f424d90a0b325480872.zip
Free the interface prototype array when Window is finalized
Fixes #1871
Diffstat (limited to 'components/script/dom/bindings/utils.rs')
-rw-r--r--components/script/dom/bindings/utils.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs
index c24c6110821..bbfadd55f84 100644
--- a/components/script/dom/bindings/utils.rs
+++ b/components/script/dom/bindings/utils.rs
@@ -321,10 +321,12 @@ pub unsafe extern fn throwing_constructor(cx: *mut JSContext, _argc: c_uint,
return 0;
}
+type ProtoOrIfaceArray = [*mut JSObject; PrototypeList::ID::Count as usize];
+
/// Construct and cache the ProtoOrIfaceArray for the given global.
/// Fails if the argument is not a DOM global.
pub fn initialize_global(global: *mut JSObject) {
- let proto_array = box ()
+ let proto_array: Box<ProtoOrIfaceArray> = box ()
([0 as *mut JSObject; PrototypeList::ID::Count as usize]);
unsafe {
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
@@ -560,6 +562,12 @@ pub fn create_dom_global(cx: *mut JSContext, class: *const JSClass)
}
}
+/// Drop the resources held by reserved slots of a global object
+pub unsafe fn finalize_global(obj: *mut JSObject) {
+ let _: Box<ProtoOrIfaceArray> =
+ Box::from_raw(get_proto_or_iface_array(obj) as *mut ProtoOrIfaceArray);
+}
+
/// Callback to outerize windows when wrapping.
pub unsafe extern fn wrap_for_same_compartment(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject {
JS_ObjectToOuterObject(cx, obj)