fix call killMe on InternalType object instead of delete 93/15393/5
Antoine ELIAS [Thu, 16 Oct 2014 14:33:31 +0000 (16:33 +0200)]
Change-Id: Iefe5c85aae5e4fab5f77e79d2fc0e0c559d196b5

scilab/modules/ast/includes/types/list.hxx
scilab/modules/ast/src/cpp/ast/expHistory.cpp
scilab/modules/ast/src/cpp/types/function.cpp
scilab/modules/ast/src/cpp/types/implicitlist.cpp
scilab/modules/ast/src/cpp/types/inspector.cpp
scilab/modules/ast/src/cpp/types/polynom.cpp
scilab/modules/ast/src/cpp/types/types_tools.cpp
scilab/modules/output_stream/src/cpp/scilabWrite.cpp

index e17c06f..8b5aed4 100644 (file)
@@ -86,7 +86,7 @@ public :
             {
                 out.push_back(pList->get(i));
             }
-            delete pList;
+            pList->killMe();
         }
 
         return true;
index 31a50ce..6ffff3d 100644 (file)
@@ -282,6 +282,11 @@ bool ExpHistory::setCurrent(types::InternalType* _pITCurrent)
         return false;
     }
 
+    if (m_pITCurrent)
+    {
+        m_pITCurrent->killMe();
+    }
+
     m_pITCurrent = _pITCurrent;
     return true;
 }
index d382f6c..aaeb203 100644 (file)
@@ -275,7 +275,10 @@ Function::ReturnValue WrapFunction::call(typed_list &in, optional_list &opt, int
 
     for (std::size_t i(0); i != MAX_OUTPUT_VARIABLE; ++i)
     {
-        delete tmpOut[i];// delete 0 is safe cf.5.3.5/2
+        if (tmpOut[i])
+        {
+            tmpOut[i]->killMe();
+        }
     }
 
     //protect outputs
@@ -291,7 +294,7 @@ Function::ReturnValue WrapFunction::call(typed_list &in, optional_list &opt, int
         {
             if (inCopy[i]->isDeletable())
             {
-                delete inCopy[i];
+                inCopy[i]->killMe();
             }
         }
     }
index 225b8d4..e5f3a2f 100644 (file)
@@ -45,28 +45,19 @@ ImplicitList::~ImplicitList()
         if (m_poStart)
         {
             m_poStart->DecreaseRef();
-            if (m_poStart->isDeletable())
-            {
-                delete m_poStart;
-            }
+            m_poStart->killMe();
         }
 
         if (m_poStep)
         {
             m_poStep->DecreaseRef();
-            if (m_poStep->isDeletable())
-            {
-                delete m_poStep;
-            }
+            m_poStep->killMe();
         }
 
         if (m_poEnd)
         {
             m_poEnd->DecreaseRef();
-            if (m_poEnd->isDeletable())
-            {
-                delete m_poEnd;
-            }
+            m_poEnd->killMe();
         }
     }
 #ifndef NDEBUG
@@ -138,11 +129,8 @@ void ImplicitList::setStart(InternalType *_poIT)
     {
         //clear previous value
         m_poStart->DecreaseRef();
-        if (m_poStart->isDeletable())
-        {
-            delete m_poStart;
-            m_poStart = NULL;
-        }
+        m_poStart->killMe();
+        m_poStart = NULL;
     }
 
     m_poStart = _poIT;
@@ -160,11 +148,8 @@ void ImplicitList::setStep(InternalType *_poIT)
     {
         //clear previous value
         m_poStep->DecreaseRef();
-        if (m_poStep->isDeletable())
-        {
-            delete m_poStep;
-            m_poStep = NULL;
-        }
+        m_poStep->killMe();
+        m_poStep = NULL;
     }
 
     m_poStep = _poIT;
@@ -182,11 +167,8 @@ void ImplicitList::setEnd(InternalType* _poIT)
     {
         //clear previous value
         m_poEnd->DecreaseRef();
-        if (m_poEnd->isDeletable())
-        {
-            delete m_poEnd;
-            m_poEnd = NULL;
-        }
+        m_poEnd->killMe();
+        m_poEnd = NULL;
     }
 
     m_poEnd = _poIT;
index a4047ba..4861c2a 100644 (file)
@@ -175,7 +175,7 @@ void Inspector::displayMemleak()
 
         // display the result
         std::wcerr << L"Memory leaked, please file a bug on http://bugzilla.scilab.org" << std::endl;
-        for (auto it = statistics.begin(); it != statistics.end(); ++it)
+        for (auto it = statistics.begin(), itEnd = statistics.end(); it != itEnd;  ++it)
         {
             std::wcerr << L"    " << it->second << L" " << it->first;
 
index e65648d..99e620c 100644 (file)
@@ -981,7 +981,7 @@ void Polynom::deleteAll()
 {
     for (int i = 0 ; i < getSize() ; i++)
     {
-        delete m_pRealData[i];
+        m_pRealData[i]->killMe();
     }
     delete[] m_pRealData;
     m_pRealData = NULL;
index 7d3a6f7..e7c0ce4 100644 (file)
@@ -62,7 +62,7 @@ int checkIndexesArguments(InternalType* _pRef, typed_list* _pArgsIn, typed_list*
                     //not enough information to compute indexes.
                     _pArgsOut->push_back(NULL);
                     bUndefine = true;
-                    delete pIL;
+                    pIL->killMe();;
                     continue;
                 }
                 //evalute polynom with "MaxDim"
@@ -86,7 +86,7 @@ int checkIndexesArguments(InternalType* _pRef, typed_list* _pArgsIn, typed_list*
             }
 
             pCurrentArg = pIL->extractFullMatrix()->getAs<Double>();
-            delete pIL;
+            pIL->killMe();
         }
         else if (pIT->isString())
         {
@@ -187,7 +187,7 @@ int checkIndexesArguments(InternalType* _pRef, typed_list* _pArgsIn, typed_list*
 
         if (bDeleteNeeded)
         {
-            delete pIT;
+            pIT->killMe();
         }
 
         if (pCurrentArg)
index 8d1f257..66ab6a3 100644 (file)
@@ -15,7 +15,6 @@
 
 extern "C"
 {
-#include "configvariable_interface.h"
 #include <stdio.h>
 #include "charEncoding.h"
 #include "sci_malloc.h"
@@ -84,4 +83,4 @@ void scilabErrorW(const wchar_t* _pwsText)
         scilabPrint(pstTemp);
         FREE(pstTemp);
     }
-}
\ No newline at end of file
+}