OSDN Git Service

DiffItem.cpp: DIFFITEM destructor should not remove its siblings
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Tue, 12 Mar 2019 13:14:44 +0000 (22:14 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Tue, 12 Mar 2019 13:14:44 +0000 (22:14 +0900)
Src/DiffItem.cpp
Src/DiffItem.h

index 18eadf0..f8e844e 100644 (file)
@@ -15,10 +15,7 @@ DIFFITEM DIFFITEM::emptyitem;
 DIFFITEM::~DIFFITEM()
 {
        RemoveChildren();
-       RemoveSiblings();
        assert(children == nullptr);
-       assert(Flink == nullptr);
-       assert(Blink == nullptr);
 }
 
 /** @brief Return path to left/right file, including all but file name */
@@ -55,26 +52,17 @@ bool DIFFITEM::IsAncestor(const DIFFITEM *pdi) const
        return false;
 }
 
-/** @brief Remove and delete all sibling DIFFITEM entries, via Flink */
-void DIFFITEM::RemoveSiblings()
+/** @brief Remove and delete all children DIFFITEM entries */
+void DIFFITEM::RemoveChildren()
 {
-       DIFFITEM *pRem = Flink;
+       DIFFITEM *pRem = children;
        while (pRem != nullptr)
        {
-               assert(pRem->parent == parent);
-               assert(pRem->Blink == this);
+               assert(pRem->parent == this);
                DIFFITEM *pNext = pRem->Flink;
-               pRem->DelinkFromSiblings();     // destroys Flink (so we use pNext instead)
                delete pRem;
                pRem = pNext;
        }
-       DelinkFromSiblings();
-}
-
-/** @brief Remove and delete all children DIFFITEM entries */
-void DIFFITEM::RemoveChildren()
-{
-       delete children;
        children = nullptr;
 }
 
@@ -167,7 +155,7 @@ void DIFFITEM::DelinkFromSiblings()
                if (parent->children == this)
                {
                        parent->children = Flink;
-                       }
+               }
        }
        if (Blink != nullptr)
                Blink->Flink = Flink;
index ea71c1d..f910966 100644 (file)
@@ -262,7 +262,6 @@ private:                                                    // Don't allow direct external manipulation of link values
                                                                                 with the first (oldest) item (pointed to by `this->parent->children`)
                                                                                 pointing to the last (newest) item. This is for easy insertion. */
        void AppendSibling(DIFFITEM *p);
-       void RemoveSiblings();
 
 public:
        void DelinkFromSiblings();