Skip to content

Commit

Permalink
Properly deallocate PrivateStyleData.
Browse files Browse the repository at this point in the history
In Servo_DropNodeData, we do Box::<NonOpaqueStyleData>::from_raw, which is off
by one level of indirection with the current types.
  • Loading branch information
bholley committed Aug 4, 2016
1 parent f0f3990 commit 1e73076
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ports/geckolib/wrapper.rs
Expand Up @@ -49,7 +49,8 @@ use style::selector_impl::ElementExt;
use style::sink::Push;
use url::Url;

pub type NonOpaqueStyleData = *mut RefCell<PrivateStyleData>;
pub type NonOpaqueStyleData = RefCell<PrivateStyleData>;
pub type NonOpaqueStyleDataPtr = *mut NonOpaqueStyleData;

// Important: We don't currently refcount the DOM, because the wrapper lifetime
// magic guarantees that our LayoutFoo references won't outlive the root, and
Expand All @@ -74,16 +75,16 @@ impl<'ln> GeckoNode<'ln> {
GeckoNode::from_raw(n as *const RawGeckoNode as *mut RawGeckoNode)
}

fn get_node_data(&self) -> NonOpaqueStyleData {
fn get_node_data(&self) -> NonOpaqueStyleDataPtr {
unsafe {
Gecko_GetNodeData(self.node) as NonOpaqueStyleData
Gecko_GetNodeData(self.node) as NonOpaqueStyleDataPtr
}
}

pub fn initialize_data(self) {
unsafe {
if self.get_node_data().is_null() {
let ptr: NonOpaqueStyleData = Box::into_raw(Box::new(RefCell::new(PrivateStyleData::new())));
let ptr: NonOpaqueStyleDataPtr = Box::into_raw(Box::new(RefCell::new(PrivateStyleData::new())));
Gecko_SetNodeData(self.node, ptr as *mut ServoNodeData);
}
}
Expand Down

0 comments on commit 1e73076

Please sign in to comment.