Assert against permanently-leaked rule nodes.

MozReview-Commit-ID: CK5iEWWHFSr
This commit is contained in:
Bobby Holley 2017-06-16 10:34:33 -07:00
parent a3b32aaa5b
commit ea81f36b1d
2 changed files with 8 additions and 3 deletions

View file

@ -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);

View file

@ -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());
}
}