Bug 1473771 - Part 1: Make LinkedList<T>::sizeOfExcludingThis work when element type inherits from multiple LinkedListElement<T>s. r=Waldo
MozReview-Commit-ID: KtqGkRKs68f
--- a/mfbt/LinkedList.h
+++ b/mfbt/LinkedList.h
@@ -553,18 +553,20 @@ public:
* Measures the memory consumption of the list excluding |this|. Note that
* it only measures the list elements themselves. If the list elements
* contain pointers to other memory blocks, those blocks must be measured
* separately during a subsequent iteration over the list.
*/
size_t sizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = 0;
- for (ConstRawType t = getFirst(); t; t = t->getNext()) {
+ ConstRawType t = getFirst();
+ while (t) {
n += aMallocSizeOf(t);
+ t = static_cast<const LinkedListElement<T>*>(t)->getNext();
}
return n;
}
/*
* Like sizeOfExcludingThis(), but measures |this| as well.
*/
size_t sizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const