Bug 544372: Fix more harmless UMRs to avoid valgrind complaining. r=sicking

This commit is contained in:
Craig Topper 2010-03-01 21:06:29 -08:00
Родитель 76a49ba9cd
Коммит 851f10e76b
2 изменённых файлов: 20 добавлений и 17 удалений

Просмотреть файл

@ -94,9 +94,14 @@ PRBool nsNodeIterator::NodePointer::MoveToPrevious(nsINode *aRoot)
return PR_TRUE;
}
void nsNodeIterator::NodePointer::AdjustAfterInsertion(nsINode *aContainer, PRInt32 aIndexInContainer)
void nsNodeIterator::NodePointer::AdjustAfterInsertion(nsINode *aRoot,
nsINode *aContainer,
PRInt32 aIndexInContainer)
{
if (!mNode)
// If mNode is null or the root there is nothing to do. This also prevents
// valgrind from complaining about consuming uninitialized memory for
// mNodeParent and mIndexInParent
if (!mNode || mNode == aRoot)
return;
// check if earlier sibling was added
@ -104,21 +109,19 @@ void nsNodeIterator::NodePointer::AdjustAfterInsertion(nsINode *aContainer, PRIn
mIndexInParent++;
}
void nsNodeIterator::NodePointer::AdjustAfterRemoval(nsINode* aRoot,
void nsNodeIterator::NodePointer::AdjustAfterRemoval(nsINode *aRoot,
nsINode *aContainer,
nsIContent *aChild,
PRInt32 aIndexInContainer)
{
if (!mNode)
// If mNode is null or the root there is nothing to do. This also prevents
// valgrind from complaining about consuming uninitialized memory for
// mNodeParent and mIndexInParent
if (!mNode || mNode == aRoot)
return;
// Check if earlier sibling was removed.
// The mNode != aRoot check isn't strictly needed because if mNode is the
// root, we'll never use mNodeParent or mIndexInParent. However without the
// check valgrind will (rightly) complain about reading uninitialized
// memory.
if (mNode != aRoot &&
aContainer == mNodeParent && aIndexInContainer < mIndexInParent) {
if (aContainer == mNodeParent && aIndexInContainer < mIndexInParent) {
--mIndexInParent;
return;
}
@ -368,15 +371,15 @@ NS_IMETHODIMP nsNodeIterator::GetPointerBeforeReferenceNode(PRBool *aBeforeNode)
* nsIMutationObserver interface
*/
void nsNodeIterator::ContentInserted(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
void nsNodeIterator::ContentInserted(nsIDocument *aDocument,
nsIContent *aContainer,
nsIContent *aChild,
PRInt32 aIndexInContainer)
{
nsINode *container = NODE_FROM(aContainer, aDocument);
mPointer.AdjustAfterInsertion(container, aIndexInContainer);
mWorkingPointer.AdjustAfterInsertion(container, aIndexInContainer);
mPointer.AdjustAfterInsertion(mRoot, container, aIndexInContainer);
mWorkingPointer.AdjustAfterInsertion(mRoot, container, aIndexInContainer);
}

Просмотреть файл

@ -83,9 +83,9 @@ private:
PRBool MoveForward(nsINode *aRoot, nsINode *aParent, PRInt32 aChildNum);
void MoveBackward(nsINode *aParent, PRInt32 aChildNum);
void AdjustAfterInsertion(nsINode *aContainer, PRInt32 aIndexInContainer);
void AdjustAfterInsertion(nsINode *aRoot, nsINode *aContainer, PRInt32 aIndexInContainer);
void AdjustAfterRemoval(nsINode *aRoot, nsINode *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer);
void Clear() { mNode = nsnull; }
nsINode *mNode;