mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Assert against permanently-leaked rule nodes.
MozReview-Commit-ID: CK5iEWWHFSr
This commit is contained in:
parent
a3b32aaa5b
commit
ea81f36b1d
2 changed files with 8 additions and 3 deletions
|
@ -122,6 +122,11 @@ impl RuleTree {
|
||||||
self.root.clone()
|
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) {
|
fn dump<W: Write>(&self, guards: &StylesheetGuards, writer: &mut W) {
|
||||||
let _ = writeln!(writer, " + RuleTree");
|
let _ = writeln!(writer, " + RuleTree");
|
||||||
self.root.get().dump(guards, writer, 0);
|
self.root.get().dump(guards, writer, 0);
|
||||||
|
|
|
@ -1283,10 +1283,10 @@ impl Drop for Stylist {
|
||||||
// dropped all strong rule node references before now, then we will
|
// 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
|
// leak them, since there will be no way to call gc() on the rule tree
|
||||||
// after this point.
|
// 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(); }
|
unsafe { self.rule_tree.gc(); }
|
||||||
|
|
||||||
|
// Assert against leaks.
|
||||||
|
debug_assert!(self.rule_tree.is_empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue