Skip to content

Commit

Permalink
Assert against permanently-leaked rule nodes.
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: CK5iEWWHFSr
  • Loading branch information
bholley committed Jun 16, 2017
1 parent a3b32aa commit ea81f36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions components/style/rule_tree/mod.rs
Expand Up @@ -122,6 +122,11 @@ impl RuleTree {
self.root.clone()
}

/// Returns true if there are no nodes in the tree aside from the rule node.
pub fn is_empty(&self) -> bool {
self.root.get().first_child.load(Ordering::Relaxed).is_null()
}

fn dump<W: Write>(&self, guards: &StylesheetGuards, writer: &mut W) {
let _ = writeln!(writer, " + RuleTree");
self.root.get().dump(guards, writer, 0);
Expand Down
6 changes: 3 additions & 3 deletions components/style/stylist.rs
Expand Up @@ -1283,10 +1283,10 @@ impl Drop for Stylist {
// dropped all strong rule node references before now, then we will
// leak them, since there will be no way to call gc() on the rule tree
// after this point.
//
// TODO(emilio): We can at least assert all the elements in the free
// list are indeed free.
unsafe { self.rule_tree.gc(); }

// Assert against leaks.
debug_assert!(self.rule_tree.is_empty());
}
}

Expand Down

0 comments on commit ea81f36

Please sign in to comment.