enable visual leak detector in all projects ( on windows and debug mode only ) 91/16391/3
Antoine ELIAS [Wed, 22 Apr 2015 07:20:57 +0000 (09:20 +0200)]
fix ast, elementary_functions, string tests memory leaks.

to use it :
 - install Visual Leak Detector ( https://vld.codeplex.com/releases )
 - add path in Visual Studio Configuration ( https://vld.codeplex.com/wikipage?title=Using%20Visual%20Leak%20Detector&referringTitle=Documentation )
 - add preprocessor flag DEBUG_VLD in Property Manager Configuration of Visual Studio.
 - Rebuild and play !

Change-Id: Icc6d7449a3e8f4f11dcb752f75805e5ba5fa5f3f

126 files changed:
scilab/modules/action_binding/src/c/DllmainAction_Binding.c
scilab/modules/api_scilab/src/c/DllmainApi_scilab.c
scilab/modules/arnoldi/src/c/DllmainArnoldi.c
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/ast/treevisitor.cpp
scilab/modules/ast/src/cpp/ast/visitor_common.cpp
scilab/modules/ast/tests/unit_tests/insert.tst
scilab/modules/ast/tests/unit_tests/sci_newtype.cpp
scilab/modules/boolean/src/c/DllmainBoolean.c
scilab/modules/cacsd/src/c/DllmainCacsd.c
scilab/modules/call_scilab/src/c/DllmainCall_scilab.c
scilab/modules/commons/src/c/DllmainCommons.c
scilab/modules/completion/src/cpp/DllmainCompletion.cpp
scilab/modules/console/src/c/DllmainConsole.c
scilab/modules/core/sci_gateway/cpp/sci_macr2tree.cpp
scilab/modules/core/src/c/DllmainCore.c
scilab/modules/core/src/cpp/InitScilab.cpp
scilab/modules/data_structures/sci_gateway/cpp/sci_getfield.cpp
scilab/modules/data_structures/src/c/DllmainData_structures.c
scilab/modules/differential_equations/includes/differentialequationfunctions.hxx
scilab/modules/differential_equations/sci_gateway/cpp/sci_bvode.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_daskr.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_dasrt.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_dassl.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_feval.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_impl.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_int2d.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_int3d.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_intg.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_ode.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_odedc.cpp
scilab/modules/differential_equations/src/c/DllmainDifferential_equations.c
scilab/modules/differential_equations/src/cpp/differentialequationfunctions.cpp
scilab/modules/dynamic_link/src/c/DllmainDynamic_link.c
scilab/modules/elementary_functions/sci_gateway/c/sci_number_properties.c
scilab/modules/elementary_functions/sci_gateway/cpp/elem_func_gw.cpp
scilab/modules/elementary_functions/src/c/DllmainElementary_functions.c
scilab/modules/external_objects_java/src/cpp/dllMain.cpp
scilab/modules/fftw/src/c/DllmainFttw.c
scilab/modules/fileio/sci_gateway/cpp/sci_getrelativefilename.cpp
scilab/modules/fileio/sci_gateway/cpp/sci_mget.cpp
scilab/modules/fileio/src/c/DllmainFileio.c
scilab/modules/functions/src/c/DllmainFunctions.c
scilab/modules/graphic_export/src/c/DllmainGraphics_export.c
scilab/modules/graphic_objects/Makefile.am
scilab/modules/graphic_objects/Makefile.in
scilab/modules/graphic_objects/includes/DataModel.hxx
scilab/modules/graphic_objects/src/c/graphic_objects.vcxproj
scilab/modules/graphic_objects/src/c/graphic_objects.vcxproj.filters
scilab/modules/graphic_objects/src/cpp/DllmainGraphic_objects.cpp [new file with mode: 0644]
scilab/modules/graphic_objects/src/cpp/ScilabView.cpp
scilab/modules/graphic_objects/src/cpp/dataModel.cpp
scilab/modules/graphic_objects/src/nographic_objects/Dllmainnographic_objects.c [moved from scilab/modules/graphic_objects/src/c/DllmainGraphic_objects.c with 84% similarity]
scilab/modules/graphic_objects/src/nographic_objects/nographic_objects.vcxproj
scilab/modules/graphic_objects/src/nographic_objects/nographic_objects.vcxproj.filters
scilab/modules/graphics/Makefile.am
scilab/modules/graphics/Makefile.in
scilab/modules/graphics/sci_gateway/c/sci_set.c
scilab/modules/graphics/src/c/DllmainGraphics.c
scilab/modules/graphics/src/c/InitObjects.c
scilab/modules/graphics/src/c/Plo2dn.c
scilab/modules/graphics/src/c/addColor.c
scilab/modules/graphics/src/c/getHandleProperty/get_position_property.c
scilab/modules/gui/sci_gateway/c/sci_figure.c
scilab/modules/gui/sci_gateway/c/sci_uicontrol.c
scilab/modules/gui/src/c/DllmainGUI.c
scilab/modules/gui/src/cpp/GetUicontrolString.cpp
scilab/modules/gui/src/cpp/GetUicontrolTooltipString.cpp
scilab/modules/gui/src/cpp/GetUicontrolUnits.cpp
scilab/modules/hdf5/src/c/DllmainHdf5.c
scilab/modules/helptools/src/c/DllmainHelptools.c
scilab/modules/history_browser/src/c/DllmainHISTORY_BROWSER.c
scilab/modules/history_manager/src/c/DllmainHistory_Manager.c
scilab/modules/integer/src/c/DllmainInteger.c
scilab/modules/interpolation/src/c/DllmainInterpolation.c
scilab/modules/io/sci_gateway/c/sci_getenv.c
scilab/modules/io/src/c/DllmainIo.c
scilab/modules/io/src/c/getenvc.c
scilab/modules/javasci/src/c/DllmainJavasci.c
scilab/modules/jvm/src/c/DllmainJvm.c
scilab/modules/jvm/src/c/JVM.c
scilab/modules/linear_algebra/src/c/DllmainLinear_algebra.c
scilab/modules/linear_algebra/src/c/eigen.c
scilab/modules/localization/src/c/DllmainLocalization.c
scilab/modules/matio/src/c/DllmainMatio.c
scilab/modules/mpi/src/c/DllmainMpi.c
scilab/modules/optimization/src/c/DllmainOptimization.c
scilab/modules/output_stream/src/c/DllmainOutput_Stream.c
scilab/modules/parallel/src/c/DllmainParallel.c
scilab/modules/parameters/src/c/DllmainParameters.c
scilab/modules/polynomials/sci_gateway/cpp/sci_roots.cpp
scilab/modules/polynomials/src/c/DllmainPolynomial.c
scilab/modules/preferences/src/c/DllmainPreferences.c
scilab/modules/randlib/src/c/DllmainRandlib.c
scilab/modules/renderer/src/c/DllmainRenderer.c
scilab/modules/scicos/src/c/DllmainScicos.c
scilab/modules/scicos_blocks/src/c/DllmainScicos_blocks.c
scilab/modules/scinotes/src/c/DllmainSCINOTES.c
scilab/modules/signal_processing/src/c/DllmainSignal_processing.c
scilab/modules/sound/src/c/DllmainSound.c
scilab/modules/sparse/src/c/DllmainSparse.c
scilab/modules/special_functions/src/c/DllmainSpecial_functions.c
scilab/modules/spreadsheet/src/c/DllmainSpreadsheet.c
scilab/modules/statistics/src/c/DllMainStatistics.c
scilab/modules/string/sci_gateway/cpp/sci_ascii.cpp
scilab/modules/string/sci_gateway/cpp/sci_grep.cpp
scilab/modules/string/sci_gateway/cpp/sci_isalphanum.cpp
scilab/modules/string/sci_gateway/cpp/sci_isascii.cpp
scilab/modules/string/sci_gateway/cpp/sci_isdigit.cpp
scilab/modules/string/sci_gateway/cpp/sci_isletter.cpp
scilab/modules/string/sci_gateway/cpp/sci_regexp.cpp
scilab/modules/string/sci_gateway/cpp/sci_strcat.cpp
scilab/modules/string/sci_gateway/cpp/sci_strcmp.cpp
scilab/modules/string/sci_gateway/cpp/sci_strsplit.cpp
scilab/modules/string/sci_gateway/cpp/string_gw.cpp
scilab/modules/string/src/c/DllMainString.c
scilab/modules/string/src/c/pcre_private.c
scilab/modules/symbolic/src/c/DllmainSymbolic.c
scilab/modules/tclsci/src/c/DllMainTclsci.c
scilab/modules/time/src/c/DllmainTime.c
scilab/modules/ui_data/src/c/DllmainUi_data.c
scilab/modules/umfpack/src/c/DllMainUmfpack.c
scilab/modules/windows_tools/src/c/DllmainWindows_Tools.c
scilab/modules/windows_tools/src/c/scilab_windows/DllmainScilab_Windows.c
scilab/modules/xcos/src/c/DllmainXCOS.c
scilab/modules/xml/src/c/DllmainXml.c

index 5960493..8b2e8c8 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index cc5ef10..85433b8 100644 (file)
 #include <stdio.h>
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib, "../../bin/libintl.lib")
 #pragma comment(lib, "../../bin/blasplus.lib")
 /*--------------------------------------------------------------------------*/
index 1c6dced..e184be8 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 #pragma comment(lib,"../../bin/arpack.lib")
 #pragma comment(lib,"../../bin/blasplus.lib")
index 4c523d4..b8c4433 100644 (file)
@@ -10,9 +10,8 @@
  *
  */
 
-//for Visual Leak Detector
-//#define DEBUG_VLD
-#if defined(DEBUG_VLD)
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
 #include <vld.h>
 #endif
 
index 8e8c374..6aa1ea4 100644 (file)
@@ -230,7 +230,6 @@ void TreeVisitor::visit(const OpExp &e)
     sub->append(getList());
     ope->append(sub);
 
-    types::String* s = new types::String(1, 1);
     switch (e.getOper())
     {
         // Arithmetics.
index f7f72f2..0bad992 100644 (file)
@@ -1679,6 +1679,7 @@ InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*>& fiel
             delete *i;
         }
 
+        _pAssignValue->killMe();
         throw error;
     }
 }
index 40ae4fe..46515c4 100644 (file)
@@ -115,6 +115,7 @@ assert_checkequal(a(2).b.num, [%s**2 %s**2 %s**2]);
 err = execstr("a.b(1,3).num = 5;", "errcatch");
 assert_checktrue(err <> 0);
 
+
 a(3).b.num = 12;
 assert_checkequal(a(3).b.num, 12);
 
@@ -515,4 +516,3 @@ assert_checktrue(err <> 0);
 st=initst();
 err=execstr("st(1:2).f(1:4).e = 5;", "errcatch");
 assert_checktrue(err <> 0);
-
index b1a28a9..2d0b17b 100644 (file)
@@ -29,14 +29,15 @@ api_scilab::Status sci_newtype(api_scilab::input &in, int _iRetCount, api_scilab
 
     if (in.size() == 1)
     {
-        if (api_scilab::isBool(in[0]) == false || api_scilab::getAsBool(in[0])->isScalar() == false)
+        api_scilab::Bool* pIn = api_scilab::getAsBool(in[0]);
+        if (pIn == NULL || pIn->isScalar() == false)
         {
             Scierror(999, _("%s: Wrong type for input argument #%d: A scalar boolean expected.\n"), "cppfoo", 1);
             return api_scilab::Error;
         }
 
-        api_scilab::Bool* pIn = api_scilab::getAsBool(in[0]);
         out.push_back(new NewType(pIn->get(0)));
+        delete pIn;
     }
     else
     {
index 271042a..0fd1a9e 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 7a46b8c..0c20f0d 100644 (file)
 #include <windows.h>
 #include "machine.h"
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 #pragma comment(lib,"../../../../bin/blasplus.lib")
 #pragma comment(lib,"../../../../bin/lapack.lib")
index b14cc23..65c5e1d 100644 (file)
 #include <stdio.h>
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index d15e7f0..4ae831c 100644 (file)
 #include <windows.h>
 #include "dynlib_commons.h"
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 COMMONS_IMPEXP int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 483b1e3..b28fd75 100644 (file)
@@ -18,6 +18,11 @@ extern "C"
     int WINAPI DllMain(HINSTANCE hInstance, DWORD reason, PVOID pvReserved);
 }
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain(HINSTANCE hInstance, DWORD reason, PVOID pvReserved)
@@ -37,8 +42,8 @@ int WINAPI DllMain(HINSTANCE hInstance, DWORD reason, PVOID pvReserved)
     return 1;
 }
 #else
-void __attribute__ ((constructor)) load(void);
-void __attribute__ ((destructor)) unload(void);
+__attribute__ ((constructor)) static void load(void);
+__attribute__ ((destructor)) static void unload(void);
 
 void load(void)
 {
index 61a93d4..15ad0b8 100644 (file)
 #include <windows.h>
 #include "../../src/c/windows/TermLine.h"
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index d83ae68..5a556f3 100644 (file)
@@ -120,5 +120,6 @@ types::Function::ReturnValue sci_macr2tree(types::typed_list &in, int _iRetCount
     //nb lines
     l->append(new types::Double(body->getLocation().last_line - body->getLocation().first_line + 1));
     out.push_back(l);
+    statement->killMe();
     return types::Function::OK;
 }
\ No newline at end of file
index 52ef3ac..60f2302 100644 (file)
@@ -9,7 +9,12 @@
 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 *
 */
-/*-----------------------------------------------------------------------------------*/
+/*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #include <windows.h>
 #include "machine.h"
 #include "stack-def.h"
index 81986ae..dd8a675 100644 (file)
@@ -298,7 +298,7 @@ int StartScilabEngine(ScilabEngineInfo* _pSEI)
             sprintf(pstCommand, "exec(\"%s\",-1)", _pSEI->pstFile);
 
             StoreConsoleCommand(pstCommand);
-
+            FREE(pstCommand);
             iMainRet = ConfigVariable::getExitStatus();
             _pSEI->pstExec = NULL;
             _pSEI->pstFile = NULL;
index cbaaa6f..36b9700 100644 (file)
@@ -181,6 +181,7 @@ types::Function::ReturnValue sci_getfield(types::typed_list &in, int _iRetCount,
                     break;
             }
 
+            pList->killMe();
             Scierror(999, _("List element number %d is Undefined.\n"), iIndex);
             return types::Function::Error;
         }
@@ -191,6 +192,8 @@ types::Function::ReturnValue sci_getfield(types::typed_list &in, int _iRetCount,
         out.push_back(pList->get(i));
     }
 
+    pList->killMe();
+
     return types::Function::OK;
 }
 /*-----------------------------------------------------------------------------------*/
index d3d8175..66902ca 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 8a227e6..dcfa635 100644 (file)
@@ -96,7 +96,7 @@ class DIFFERENTIAL_EQUATIONS_IMPEXP DifferentialEquationFunctions
 
 public :
 
-    DifferentialEquationFunctions(std::wstring callerName);
+    DifferentialEquationFunctions(const std::wstring& callerName);
     ~DifferentialEquationFunctions();
 
     void setOdeYRows(int);
index 1bcd887..571c106 100644 (file)
@@ -405,10 +405,10 @@ types::Function::ReturnValue sci_bvode(types::typed_list &in, int _iRetCount, ty
     iPos++;
 
     // functions: fsub,dfsub,gsub,dgsub,guess
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"bvode");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
-    deFunctionsManager->setBvodeM(sumM);
-    deFunctionsManager->setBvodeN(ncomp);
+    DifferentialEquationFunctions deFunctionsManager(L"bvode");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
+    deFunctionsManager.setBvodeM(sumM);
+    deFunctionsManager.setBvodeN(ncomp);
 
     for (int i = iPos; i < 15; i++)
     {
@@ -417,23 +417,23 @@ types::Function::ReturnValue sci_bvode(types::typed_list &in, int _iRetCount, ty
             types::Callable* pCall = in[i]->getAs<types::Callable>();
             if (i == 10) // fsub
             {
-                deFunctionsManager->setFsubFunction(pCall);
+                deFunctionsManager.setFsubFunction(pCall);
             }
             else if (i == 11) // dfsub
             {
-                deFunctionsManager->setDfsubFunction(pCall);
+                deFunctionsManager.setDfsubFunction(pCall);
             }
             else if (i == 12) // gsub
             {
-                deFunctionsManager->setGsubFunction(pCall);
+                deFunctionsManager.setGsubFunction(pCall);
             }
             else if (i == 13) // dgsub
             {
-                deFunctionsManager->setDgsubFunction(pCall);
+                deFunctionsManager.setDgsubFunction(pCall);
             }
             else if (i == 14 && ipar[8] == 1) // guess is needed only if ipar(9) == 1
             {
-                deFunctionsManager->setGuessFunction(pCall);
+                deFunctionsManager.setGuessFunction(pCall);
             }
         }
         else if (in[i]->isString())
@@ -442,23 +442,23 @@ types::Function::ReturnValue sci_bvode(types::typed_list &in, int _iRetCount, ty
             types::String* pStr = in[i]->getAs<types::String>();
             if (i == 10) // fsub
             {
-                bOK = deFunctionsManager->setFsubFunction(pStr);
+                bOK = deFunctionsManager.setFsubFunction(pStr);
             }
             else if (i == 11) // dfsub
             {
-                bOK = deFunctionsManager->setDfsubFunction(pStr);
+                bOK = deFunctionsManager.setDfsubFunction(pStr);
             }
             else if (i == 12) // gsub
             {
-                bOK = deFunctionsManager->setGsubFunction(pStr);
+                bOK = deFunctionsManager.setGsubFunction(pStr);
             }
             else if (i == 13) // dgsub
             {
-                bOK = deFunctionsManager->setDgsubFunction(pStr);
+                bOK = deFunctionsManager.setDgsubFunction(pStr);
             }
             else if (i == 14 && ipar[8] == 1) // guess is needed only if ipar(9) == 1
             {
-                bOK = deFunctionsManager->setGuessFunction(pStr);
+                bOK = deFunctionsManager.setGuessFunction(pStr);
             }
 
             if (bOK == false)
@@ -487,42 +487,42 @@ types::Function::ReturnValue sci_bvode(types::typed_list &in, int _iRetCount, ty
             {
                 if (i == 10) // fsub
                 {
-                    deFunctionsManager->setFsubFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setFsubFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setFsubArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setFsubArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (i == 11) // dfsub
                 {
-                    deFunctionsManager->setDfsubFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setDfsubFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setDfsubArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setDfsubArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (i == 12) // gsub
                 {
-                    deFunctionsManager->setGsubFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setGsubFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setGsubArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setGsubArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (i == 13) // dgsub
                 {
-                    deFunctionsManager->setDgsubFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setDgsubFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setDgsubArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setDgsubArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (i == 14 && ipar[8] == 1) // guess is needed only if ipar(9) == 1
                 {
-                    deFunctionsManager->setGuessFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setGuessFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setGuessArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setGuessArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
             }
index 2a6fac9..e133571 100644 (file)
@@ -191,10 +191,10 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
     }
 
     // get next inputs
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"daskr");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
+    DifferentialEquationFunctions deFunctionsManager(L"daskr");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
 
-    deFunctionsManager->setOdeYRows(pDblX0->getRows());
+    deFunctionsManager.setOdeYRows(pDblX0->getRows());
 
     for (iPos++; iPos < in.size(); iPos++)
     {
@@ -268,27 +268,27 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
             types::Callable* pCall = in[iPos]->getAs<types::Callable>();
             if (bFuncF == false)
             {
-                deFunctionsManager->setFFunction(pCall);
+                deFunctionsManager.setFFunction(pCall);
                 bFuncF = true;
             }
             else if (bFuncJac == false && pDblNg == NULL)
             {
-                deFunctionsManager->setJacFunction(pCall);
+                deFunctionsManager.setJacFunction(pCall);
                 bFuncJac = true;
             }
             else if (bFuncG == false && pDblNg)
             {
-                deFunctionsManager->setGFunction(pCall);
+                deFunctionsManager.setGFunction(pCall);
                 bFuncG = true;
             }
             else if (bFuncG && bFuncPsol == false)
             {
-                deFunctionsManager->setPsolFunction(pCall);
+                deFunctionsManager.setPsolFunction(pCall);
                 bFuncPsol = true;
             }
             else if (bFuncPsol && bFuncPjac == false)
             {
-                deFunctionsManager->setPjacFunction(pCall);
+                deFunctionsManager.setPjacFunction(pCall);
                 bFuncPjac = true;
             }
             else
@@ -308,27 +308,27 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
 
             if (bFuncF == false)
             {
-                bOK = deFunctionsManager->setFFunction(pStr);
+                bOK = deFunctionsManager.setFFunction(pStr);
                 bFuncF = true;
             }
             else if (bFuncJac == false && pDblNg == NULL)
             {
-                bOK = deFunctionsManager->setJacFunction(pStr);
+                bOK = deFunctionsManager.setJacFunction(pStr);
                 bFuncJac = true;
             }
             else if (bFuncG == false && pDblNg)
             {
-                bOK = deFunctionsManager->setGFunction(pStr);
+                bOK = deFunctionsManager.setGFunction(pStr);
                 bFuncG = true;
             }
             else if (bFuncG && bFuncPsol == false)
             {
-                bOK = deFunctionsManager->setPsolFunction(pStr);
+                bOK = deFunctionsManager.setPsolFunction(pStr);
                 bFuncPsol = true;
             }
             else if (bFuncPsol && bFuncPjac == false)
             {
-                bOK = deFunctionsManager->setPjacFunction(pStr);
+                bOK = deFunctionsManager.setPjacFunction(pStr);
                 bFuncPjac = true;
             }
             else
@@ -388,26 +388,26 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    bOK = deFunctionsManager->setFFunction(pStr);
+                    bOK = deFunctionsManager.setFFunction(pStr);
                 }
                 else if (bFuncJac == false && pDblNg == NULL)
                 {
                     bFuncJac = true;
-                    bOK = deFunctionsManager->setJacFunction(pStr);
+                    bOK = deFunctionsManager.setJacFunction(pStr);
                 }
                 else if (bFuncG == false && pDblNg)
                 {
                     bFuncG = true;
-                    bOK = deFunctionsManager->setGFunction(pStr);
+                    bOK = deFunctionsManager.setGFunction(pStr);
                 }
                 else if (bFuncG && bFuncPsol == false)
                 {
-                    bOK = deFunctionsManager->setPsolFunction(pStr);
+                    bOK = deFunctionsManager.setPsolFunction(pStr);
                     bFuncPsol = true;
                 }
                 else if (bFuncPsol && bFuncPjac == false)
                 {
-                    bOK = deFunctionsManager->setPjacFunction(pStr);
+                    bOK = deFunctionsManager.setPjacFunction(pStr);
                     bFuncPjac = true;
                 }
 
@@ -469,46 +469,46 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncJac == false && pDblNg == NULL)
                 {
                     bFuncJac = true;
-                    deFunctionsManager->setJacFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setJacFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setJacArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setJacArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncG == false && pDblNg)
                 {
                     bFuncG = true;
-                    deFunctionsManager->setGFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setGFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setGArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setGArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncG && bFuncPsol == false)
                 {
                     bFuncPsol = true;
-                    deFunctionsManager->setPsolFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setPsolFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setPsolArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setPsolArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncPsol && bFuncPjac == false)
                 {
                     bFuncPjac = true;
-                    deFunctionsManager->setPjacFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setPjacFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setPjacArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setPjacArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
             }
@@ -563,8 +563,8 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
                     info[5] = 1;
                     ml = (int)pDblTemp->get(0);
                     mu = (int)pDblTemp->get(1);
-                    deFunctionsManager->setMl(ml);
-                    deFunctionsManager->setMu(mu);
+                    deFunctionsManager.setMl(ml);
+                    deFunctionsManager.setMu(mu);
                 }
                 else if (pDblTemp->getSize() != 0)
                 {
@@ -947,7 +947,7 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
     {
         for (int i = 0; i < pDblX0->getRows(); i++)
         {
-            iwork[LID + i] = pDblE7->get(i);
+            iwork[LID + i] = static_cast<int>(pDblE7->get(i));
         }
     }
 
@@ -981,7 +981,7 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
     {
         for (int i = 0; i < pDblX0->getRows(); i++)
         {
-            iwork[LID + i] = pDblE12->get(i);
+            iwork[LID + i] = static_cast<int>(pDblE12->get(i));
         }
     }
 
index d24a36f..3c2595a 100644 (file)
@@ -149,8 +149,8 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
     }
 
     // get next inputs
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"dasrt");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
+    DifferentialEquationFunctions deFunctionsManager(L"dasrt");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
 
     YSize = (int*)MALLOC(sizeOfYSize * sizeof(int));
     *YSize = pDblX0->getRows();
@@ -168,7 +168,7 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
         memset(pdYdotData, 0x00, *YSize);
     }
 
-    deFunctionsManager->setOdeYRows(pDblX0->getRows());
+    deFunctionsManager.setOdeYRows(pDblX0->getRows());
 
     for (iPos++; iPos < in.size(); iPos++)
     {
@@ -242,17 +242,17 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
             types::Callable* pCall = in[iPos]->getAs<types::Callable>();
             if (bFuncF == false)
             {
-                deFunctionsManager->setFFunction(pCall);
+                deFunctionsManager.setFFunction(pCall);
                 bFuncF = true;
             }
             else if (bFuncJac == false && pDblNg == NULL)
             {
-                deFunctionsManager->setJacFunction(pCall);
+                deFunctionsManager.setJacFunction(pCall);
                 bFuncJac = true;
             }
             else if (bFuncG == false && pDblNg)
             {
-                deFunctionsManager->setGFunction(pCall);
+                deFunctionsManager.setGFunction(pCall);
                 bFuncG = true;
             }
             else
@@ -272,17 +272,17 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
 
             if (bFuncF == false)
             {
-                bOK = deFunctionsManager->setFFunction(pStr);
+                bOK = deFunctionsManager.setFFunction(pStr);
                 bFuncF = true;
             }
             else if (bFuncJac == false && pDblNg == NULL)
             {
-                bOK = deFunctionsManager->setJacFunction(pStr);
+                bOK = deFunctionsManager.setJacFunction(pStr);
                 bFuncJac = true;
             }
             else if (bFuncG == false && pDblNg)
             {
-                bOK = deFunctionsManager->setGFunction(pStr);
+                bOK = deFunctionsManager.setGFunction(pStr);
                 bFuncG = true;
             }
             else
@@ -339,13 +339,13 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    bOK = deFunctionsManager->setFFunction(pStr);
+                    bOK = deFunctionsManager.setFFunction(pStr);
                     sizeOfpdYData = *YSize;
                 }
                 else if (bFuncJac == false && pDblNg == NULL)
                 {
                     bFuncJac = true;
-                    bOK = deFunctionsManager->setJacFunction(pStr);
+                    bOK = deFunctionsManager.setJacFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -354,7 +354,7 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
                 else if (bFuncG == false && pDblNg)
                 {
                     bFuncG = true;
-                    bOK = deFunctionsManager->setGFunction(pStr);
+                    bOK = deFunctionsManager.setGFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -418,28 +418,28 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncJac == false && pDblNg == NULL)
                 {
                     bFuncJac = true;
-                    deFunctionsManager->setJacFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setJacFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setJacArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setJacArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncG == false && pDblNg)
                 {
                     bFuncG = true;
-                    deFunctionsManager->setGFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setGFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setGArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setGArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
             }
@@ -490,8 +490,8 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
                     info[5] = 1;
                     ml = (int)pDblTemp->get(0);
                     mu = (int)pDblTemp->get(1);
-                    deFunctionsManager->setMl(ml);
-                    deFunctionsManager->setMu(mu);
+                    deFunctionsManager.setMl(ml);
+                    deFunctionsManager.setMu(mu);
                 }
                 else if (pDblTemp->getSize() != 0)
                 {
index cccbbc9..cbc4a09 100644 (file)
@@ -148,8 +148,8 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
     }
 
     // get next inputs
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"dassl");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
+    DifferentialEquationFunctions deFunctionsManager(L"dassl");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
 
     YSize = (int*)MALLOC(sizeOfYSize * sizeof(int));
     *YSize = pDblX0->getRows();
@@ -167,7 +167,7 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
         memset(pdYdotData, 0x00, *YSize);
     }
 
-    deFunctionsManager->setOdeYRows(pDblX0->getRows());
+    deFunctionsManager.setOdeYRows(pDblX0->getRows());
 
     for (iPos++; iPos < in.size(); iPos++)
     {
@@ -227,12 +227,12 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
             types::Callable* pCall = in[iPos]->getAs<types::Callable>();
             if (bFuncF == false)
             {
-                deFunctionsManager->setFFunction(pCall);
+                deFunctionsManager.setFFunction(pCall);
                 bFuncF = true;
             }
             else if (bFuncJac == false)
             {
-                deFunctionsManager->setJacFunction(pCall);
+                deFunctionsManager.setJacFunction(pCall);
                 bFuncJac = true;
             }
             else
@@ -252,12 +252,12 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
 
             if (bFuncF == false)
             {
-                bOK = deFunctionsManager->setFFunction(pStr);
+                bOK = deFunctionsManager.setFFunction(pStr);
                 bFuncF = true;
             }
             else if (bFuncJac == false)
             {
-                bOK = deFunctionsManager->setJacFunction(pStr);
+                bOK = deFunctionsManager.setJacFunction(pStr);
                 bFuncJac = true;
             }
             else
@@ -314,13 +314,13 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    bOK = deFunctionsManager->setFFunction(pStr);
+                    bOK = deFunctionsManager.setFFunction(pStr);
                     sizeOfpdYData = *YSize;
                 }
                 else if (bFuncJac == false)
                 {
                     bFuncJac = true;
-                    bOK = deFunctionsManager->setJacFunction(pStr);
+                    bOK = deFunctionsManager.setJacFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -384,19 +384,19 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncJac == false)
                 {
                     bFuncJac = true;
-                    deFunctionsManager->setJacFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setJacFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setJacArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setJacArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
             }
@@ -447,8 +447,8 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
                     info[5] = 1;
                     ml = (int)pDblTemp->get(0);
                     mu = (int)pDblTemp->get(1);
-                    deFunctionsManager->setMl(ml);
-                    deFunctionsManager->setMu(mu);
+                    deFunctionsManager.setMl(ml);
+                    deFunctionsManager.setMu(mu);
                 }
                 else if (pDblTemp->getSize() != 0)
                 {
index 3064e97..e9d3841 100644 (file)
@@ -95,19 +95,19 @@ types::Function::ReturnValue sci_feval(types::typed_list &in, int _iRetCount, ty
     }
 
     // function
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"feval");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
+    DifferentialEquationFunctions deFunctionsManager(L"feval");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
 
     if (in[iPos]->isCallable())
     {
         types::Callable* pCall = in[iPos]->getAs<types::Callable>();
-        deFunctionsManager->setFFunction(pCall);
+        deFunctionsManager.setFFunction(pCall);
     }
     else if (in[iPos]->isString())
     {
         bool bOK = false;
         types::String* pStr = in[iPos]->getAs<types::String>();
-        bOK = deFunctionsManager->setFFunction(pStr);
+        bOK = deFunctionsManager.setFFunction(pStr);
 
         if (bOK == false)
         {
@@ -131,10 +131,10 @@ types::Function::ReturnValue sci_feval(types::typed_list &in, int _iRetCount, ty
 
         if (pList->get(0)->isCallable())
         {
-            deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+            deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
             for (int iter = 1; iter < pList->getSize(); iter++)
             {
-                deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
             }
         }
         else
@@ -175,7 +175,7 @@ types::Function::ReturnValue sci_feval(types::typed_list &in, int _iRetCount, ty
 
             try
             {
-                deFunctionsManager->execFevalF(&nn, &valX, &valY, res, &itype);
+                deFunctionsManager.execFevalF(&nn, &valX, &valY, res, &itype);
             }
             catch (ast::ScilabMessage &sm)
             {
index c398eb6..74b52c1 100644 (file)
@@ -190,8 +190,8 @@ types::Function::ReturnValue sci_impl(types::typed_list &in, int _iRetCount, typ
     pDblT = in[iPos]->getAs<types::Double>();
 
     // get next inputs
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"impl");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
+    DifferentialEquationFunctions deFunctionsManager(L"impl");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
 
     YSize = (int*)malloc(sizeOfYSize * sizeof(int));
     *YSize = pDblY0->getSize();
@@ -266,17 +266,17 @@ types::Function::ReturnValue sci_impl(types::typed_list &in, int _iRetCount, typ
             types::Callable* pCall = in[iPos]->getAs<types::Callable>();
             if (bFuncF == false)
             {
-                deFunctionsManager->setFFunction(pCall);
+                deFunctionsManager.setFFunction(pCall);
                 bFuncF = true;
             }
             else if (bFuncG == false)
             {
-                deFunctionsManager->setGFunction(pCall);
+                deFunctionsManager.setGFunction(pCall);
                 bFuncG = true;
             }
             else if (bFuncJac == false)
             {
-                deFunctionsManager->setJacFunction(pCall);
+                deFunctionsManager.setJacFunction(pCall);
                 bFuncJac = true;
             }
             else
@@ -295,17 +295,17 @@ types::Function::ReturnValue sci_impl(types::typed_list &in, int _iRetCount, typ
 
             if (bFuncF == false)
             {
-                bOK = deFunctionsManager->setFFunction(pStr);
+                bOK = deFunctionsManager.setFFunction(pStr);
                 bFuncF = true;
             }
             else if (bFuncG == false)
             {
-                bOK = deFunctionsManager->setGFunction(pStr);
+                bOK = deFunctionsManager.setGFunction(pStr);
                 bFuncG = true;
             }
             else if (bFuncJac == false)
             {
-                bOK = deFunctionsManager->setJacFunction(pStr);
+                bOK = deFunctionsManager.setJacFunction(pStr);
                 bFuncJac = true;
             }
             else
@@ -358,13 +358,13 @@ types::Function::ReturnValue sci_impl(types::typed_list &in, int _iRetCount, typ
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    bOK = deFunctionsManager->setFFunction(pStr);
+                    bOK = deFunctionsManager.setFFunction(pStr);
                     sizeOfpdYData = *YSize;
                 }
                 else if (bFuncG == false)
                 {
                     bFuncG = true;
-                    bOK = deFunctionsManager->setGFunction(pStr);
+                    bOK = deFunctionsManager.setGFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -373,7 +373,7 @@ types::Function::ReturnValue sci_impl(types::typed_list &in, int _iRetCount, typ
                 else if (bFuncJac == false)
                 {
                     bFuncJac = true;
-                    bOK = deFunctionsManager->setJacFunction(pStr);
+                    bOK = deFunctionsManager.setJacFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -435,28 +435,28 @@ types::Function::ReturnValue sci_impl(types::typed_list &in, int _iRetCount, typ
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncG == false)
                 {
                     bFuncG = true;
-                    deFunctionsManager->setGFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setGFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setGArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setGArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncJac == false)
                 {
                     bFuncJac = true;
-                    deFunctionsManager->setJacFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setJacFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setJacArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setJacArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
             }
index 8364076..4db8a0b 100644 (file)
@@ -115,13 +115,13 @@ types::Function::ReturnValue sci_int2d(types::typed_list &in, int _iRetCount, ty
 
 
     // function
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"int2d");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
+    DifferentialEquationFunctions deFunctionsManager(L"int2d");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
 
     if (in[2]->isCallable())
     {
         types::Callable* pCall = in[2]->getAs<types::Callable>();
-        deFunctionsManager->setFFunction(pCall);
+        deFunctionsManager.setFFunction(pCall);
 
         // check function
         double x = 1;
@@ -138,7 +138,7 @@ types::Function::ReturnValue sci_int2d(types::typed_list &in, int _iRetCount, ty
     {
         bool bOK = false;
         types::String* pStr = in[2]->getAs<types::String>();
-        bOK = deFunctionsManager->setFFunction(pStr);
+        bOK = deFunctionsManager.setFFunction(pStr);
 
         if (bOK == false)
         {
@@ -162,10 +162,10 @@ types::Function::ReturnValue sci_int2d(types::typed_list &in, int _iRetCount, ty
 
         if (pList->get(0)->isCallable())
         {
-            deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+            deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
             for (int iter = 1; iter < pList->getSize(); iter++)
             {
-                deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
             }
         }
         else
index 314e8ad..90e0734 100644 (file)
@@ -138,19 +138,19 @@ types::Function::ReturnValue sci_int3d(types::typed_list &in, int _iRetCount, ty
     }
 
     // function
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"int3d");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
+    DifferentialEquationFunctions deFunctionsManager(L"int3d");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
 
     if (in[3]->isCallable())
     {
         types::Callable* pCall = in[3]->getAs<types::Callable>();
-        deFunctionsManager->setFFunction(pCall);
+        deFunctionsManager.setFFunction(pCall);
     }
     else if (in[3]->isString())
     {
         bool bOK = false;
         types::String* pStr = in[3]->getAs<types::String>();
-        bOK = deFunctionsManager->setFFunction(pStr);
+        bOK = deFunctionsManager.setFFunction(pStr);
 
         if (bOK == false)
         {
@@ -174,10 +174,10 @@ types::Function::ReturnValue sci_int3d(types::typed_list &in, int _iRetCount, ty
 
         if (pList->get(0)->isCallable())
         {
-            deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+            deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
             for (int iter = 1; iter < pList->getSize(); iter++)
             {
-                deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
             }
         }
         else
index 97cbfee..4b9793b 100644 (file)
@@ -111,13 +111,13 @@ types::Function::ReturnValue sci_intg(types::typed_list &in, int _iRetCount, typ
     }
 
     // function
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"intg");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
+    DifferentialEquationFunctions deFunctionsManager(L"intg");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
 
     if (in[2]->isCallable())
     {
         types::Callable* pCall = in[2]->getAs<types::Callable>();
-        deFunctionsManager->setFFunction(pCall);
+        deFunctionsManager.setFFunction(pCall);
 
         // check function
         double t = 1;
@@ -133,7 +133,7 @@ types::Function::ReturnValue sci_intg(types::typed_list &in, int _iRetCount, typ
     {
         bool bOK = false;
         types::String* pStr = in[2]->getAs<types::String>();
-        bOK = deFunctionsManager->setFFunction(pStr);
+        bOK = deFunctionsManager.setFFunction(pStr);
 
         if (bOK == false)
         {
@@ -157,10 +157,10 @@ types::Function::ReturnValue sci_intg(types::typed_list &in, int _iRetCount, typ
 
         if (pList->get(0)->isCallable())
         {
-            deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+            deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
             for (int iter = 1; iter < pList->getSize(); iter++)
             {
-                deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
             }
         }
         else
index ce0fa27..281ecba 100644 (file)
@@ -237,10 +237,10 @@ types::Function::ReturnValue sci_ode(types::typed_list &in, int _iRetCount, type
     pDblT = in[iPos]->getAs<types::Double>();
 
     // get next inputs
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"ode");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
-    deFunctionsManager->setOdeYRows(pDblY0->getRows());
-    deFunctionsManager->setOdeYCols(pDblY0->getCols());
+    DifferentialEquationFunctions deFunctionsManager(L"ode");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
+    deFunctionsManager.setOdeYRows(pDblY0->getRows());
+    deFunctionsManager.setOdeYCols(pDblY0->getCols());
 
     YSize = (int*)MALLOC(sizeOfYSize * sizeof(int));
     *YSize = pDblY0->getSize();
@@ -340,17 +340,17 @@ types::Function::ReturnValue sci_ode(types::typed_list &in, int _iRetCount, type
             types::Callable* pCall = in[iPos]->getAs<types::Callable>();
             if (bFuncF == false)
             {
-                deFunctionsManager->setFFunction(pCall);
+                deFunctionsManager.setFFunction(pCall);
                 bFuncF = true;
             }
             else if (bFuncJac == false && (pDblNg == NULL || meth != 3))
             {
-                deFunctionsManager->setJacFunction(pCall);
+                deFunctionsManager.setJacFunction(pCall);
                 bFuncJac = true;
             }
             else if (bFuncG == false && meth == 3)
             {
-                deFunctionsManager->setGFunction(pCall);
+                deFunctionsManager.setGFunction(pCall);
                 bFuncG = true;
             }
             else
@@ -369,17 +369,17 @@ types::Function::ReturnValue sci_ode(types::typed_list &in, int _iRetCount, type
 
             if (bFuncF == false)
             {
-                bOK = deFunctionsManager->setFFunction(pStr);
+                bOK = deFunctionsManager.setFFunction(pStr);
                 bFuncF = true;
             }
             else if (bFuncJac == false && (pDblNg == NULL || meth != 3))
             {
-                bOK = deFunctionsManager->setJacFunction(pStr);
+                bOK = deFunctionsManager.setJacFunction(pStr);
                 bFuncJac = true;
             }
             else if (bFuncG == false && meth == 3)
             {
-                bOK = deFunctionsManager->setGFunction(pStr);
+                bOK = deFunctionsManager.setGFunction(pStr);
                 bFuncG = true;
             }
             else
@@ -432,13 +432,13 @@ types::Function::ReturnValue sci_ode(types::typed_list &in, int _iRetCount, type
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    bOK = deFunctionsManager->setFFunction(pStr);
+                    bOK = deFunctionsManager.setFFunction(pStr);
                     sizeOfpdYData = *YSize;
                 }
                 else if (bFuncJac == false && (pDblNg == NULL || meth != 3))
                 {
                     bFuncJac = true;
-                    bOK = deFunctionsManager->setJacFunction(pStr);
+                    bOK = deFunctionsManager.setJacFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -447,7 +447,7 @@ types::Function::ReturnValue sci_ode(types::typed_list &in, int _iRetCount, type
                 else if (bFuncG == false && meth == 3)
                 {
                     bFuncG = true;
-                    bOK = deFunctionsManager->setGFunction(pStr);
+                    bOK = deFunctionsManager.setGFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -509,28 +509,28 @@ types::Function::ReturnValue sci_ode(types::typed_list &in, int _iRetCount, type
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncJac == false && (pDblNg == NULL || meth != 3))
                 {
                     bFuncJac = true;
-                    deFunctionsManager->setJacFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setJacFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setJacArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setJacArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncG == false && meth == 3)
                 {
                     bFuncG = true;
-                    deFunctionsManager->setGFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setGFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setGArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setGArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
             }
index ec1ef3f..1ca6c30 100644 (file)
@@ -269,11 +269,11 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
     }
 
     // get next inputs
-    DifferentialEquationFunctions* deFunctionsManager = new DifferentialEquationFunctions(L"odedc");
-    DifferentialEquation::addDifferentialEquationFunctions(deFunctionsManager);
-    deFunctionsManager->setOdedcYDSize((int)pDblNd->get(0));
-    deFunctionsManager->setOdeYRows(pDblY0->getRows());
-    deFunctionsManager->setOdeYCols(pDblY0->getCols());
+    DifferentialEquationFunctions deFunctionsManager(L"odedc");
+    DifferentialEquation::addDifferentialEquationFunctions(&deFunctionsManager);
+    deFunctionsManager.setOdedcYDSize((int)pDblNd->get(0));
+    deFunctionsManager.setOdeYRows(pDblY0->getRows());
+    deFunctionsManager.setOdeYCols(pDblY0->getCols());
 
     YSize = (int*)MALLOC(sizeOfYSize * sizeof(int));
     *YSize = pDblY0->getSize();
@@ -373,17 +373,17 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
             types::Callable* pCall = in[iPos]->getAs<types::Callable>();
             if (bFuncF == false)
             {
-                deFunctionsManager->setFFunction(pCall);
+                deFunctionsManager.setFFunction(pCall);
                 bFuncF = true;
             }
             else if (bFuncJac == false && (pDblNg == NULL || meth != 3))
             {
-                deFunctionsManager->setJacFunction(pCall);
+                deFunctionsManager.setJacFunction(pCall);
                 bFuncJac = true;
             }
             else if (bFuncG == false && meth == 3)
             {
-                deFunctionsManager->setGFunction(pCall);
+                deFunctionsManager.setGFunction(pCall);
                 bFuncG = true;
             }
             else
@@ -402,17 +402,17 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
 
             if (bFuncF == false)
             {
-                bOK = deFunctionsManager->setFFunction(pStr);
+                bOK = deFunctionsManager.setFFunction(pStr);
                 bFuncF = true;
             }
             else if (bFuncJac == false && (pDblNg == NULL || meth != 3))
             {
-                bOK = deFunctionsManager->setJacFunction(pStr);
+                bOK = deFunctionsManager.setJacFunction(pStr);
                 bFuncJac = true;
             }
             else if (bFuncG == false && meth == 3)
             {
-                bOK = deFunctionsManager->setGFunction(pStr);
+                bOK = deFunctionsManager.setGFunction(pStr);
                 bFuncG = true;
             }
             else
@@ -465,13 +465,13 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    bOK = deFunctionsManager->setFFunction(pStr);
+                    bOK = deFunctionsManager.setFFunction(pStr);
                     sizeOfpdYData = *YSize;
                 }
                 else if (bFuncJac == false && (pDblNg == NULL || meth != 3))
                 {
                     bFuncJac = true;
-                    bOK = deFunctionsManager->setJacFunction(pStr);
+                    bOK = deFunctionsManager.setJacFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -480,7 +480,7 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
                 else if (bFuncG == false && meth == 3)
                 {
                     bFuncG = true;
-                    bOK = deFunctionsManager->setGFunction(pStr);
+                    bOK = deFunctionsManager.setGFunction(pStr);
                     if (sizeOfpdYData == 0)
                     {
                         sizeOfpdYData = *YSize;
@@ -543,28 +543,28 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
                 if (bFuncF == false)
                 {
                     bFuncF = true;
-                    deFunctionsManager->setFFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setFFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setFArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setFArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncJac == false && (pDblNg == NULL || meth != 3))
                 {
                     bFuncJac = true;
-                    deFunctionsManager->setJacFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setJacFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setJacArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setJacArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
                 else if (bFuncG == false && meth == 3)
                 {
                     bFuncG = true;
-                    deFunctionsManager->setGFunction(pList->get(0)->getAs<types::Callable>());
+                    deFunctionsManager.setGFunction(pList->get(0)->getAs<types::Callable>());
                     for (int iter = 1; iter < pList->getSize(); iter++)
                     {
-                        deFunctionsManager->setGArgs(pList->get(iter)->getAs<types::InternalType>());
+                        deFunctionsManager.setGArgs(pList->get(iter)->getAs<types::InternalType>());
                     }
                 }
             }
@@ -1090,7 +1090,7 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
             if (fabs(tleft - hf) < 1.0e-12) // update discrete part
             {
                 bIntegrateContPart = false;
-                deFunctionsManager->setOdedcFlag();
+                deFunctionsManager.setOdedcFlag();
 
                 if (pDblOdeOptions && pDblOdeOptions->get(9) == 1)
                 {
@@ -1144,7 +1144,7 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
                     throw ast::ScilabMessage(os.str());
                 }
 
-                deFunctionsManager->resetOdedcFlag();
+                deFunctionsManager.resetOdedcFlag();
                 nhpass++;
 
                 double* copy = (double*)MALLOC(*YSize * sizeof(double));
@@ -1473,7 +1473,7 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
 
             if (bUpdate)
             {
-                deFunctionsManager->setOdedcFlag();
+                deFunctionsManager.setOdedcFlag();
 
                 if (pDblOdeOptions && pDblOdeOptions->get(9) == 1)
                 {
@@ -1527,7 +1527,7 @@ types::Function::ReturnValue sci_odedc(types::typed_list &in, int _iRetCount, ty
                     throw ast::ScilabMessage(os.str());
                 }
 
-                deFunctionsManager->resetOdedcFlag();
+                deFunctionsManager.resetOdedcFlag();
                 nhpass++;
             }
 
index 240726b..d5c88c4 100644 (file)
 #include "common_structure.h"
 #include "dynlib_differential_equations.h"
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 
index e5ed1c7..9c6f776 100644 (file)
@@ -60,7 +60,7 @@ DifferentialEquationFunctions* DifferentialEquation::getDifferentialEquationFunc
 
 
 /*--------------------------------------------------------------------------*/
-DifferentialEquationFunctions::DifferentialEquationFunctions(std::wstring callerName)
+DifferentialEquationFunctions::DifferentialEquationFunctions(const std::wstring& callerName)
 {
     m_odeYRows      = 0;
     m_odeYCols      = 0;
index d9be569..63387f5 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 59e464e..db7ac5f 100644 (file)
@@ -23,17 +23,17 @@ int sci_number_properties(char *fname, void* pvApiCtx)
 {
     SciErr sciErr;
     int i;
-    int iRet                           = 0;
+    int iRet = 0;
 
-    int iRows                          = 0;
-    int iCols                          = 0;
-    char **pstData     = NULL;
-    int* piAddr                        = NULL;
+    int iRows = 0;
+    int iCols = 0;
+    char **pstData = NULL;
+    int* piAddr = NULL;
 
-    double dblRet              = 0;
-    int bRet                           = 0;
+    double dblRet = 0;
+    int bRet = 0;
 
-    int bBoolFlag              = 0;
+    int bBoolFlag = 0;
 
     CheckRhs(1, 1);
     CheckLhs(1, 1);
@@ -109,11 +109,14 @@ int sci_number_properties(char *fname, void* pvApiCtx)
     }
     else
     {
+        freeAllocatedMatrixOfString(iRows, iCols, pstData);
         sciprint(_("%s: unknown property kind.\n"), fname);
         SciError(999);
         return 0;
     }
 
+    freeAllocatedMatrixOfString(iRows, iCols, pstData);
+
     if (bBoolFlag)
     {
         iRet = createScalarBoolean(pvApiCtx, Rhs + 1, bRet);
index 319554a..35805a4 100644 (file)
@@ -10,8 +10,8 @@
 *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 *
 */
-//for Visual Leak Detector
-#ifdef DEBUG_VLD
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
 #include <vld.h>
 #endif
 
index b74129d..d7643d8 100644 (file)
 
 #include <windows.h>
 
-//for Visual Leak Detector
-#ifdef DEBUG_VLD
+/*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
 #include <vld.h>
 #endif
-
 /*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
index 9faa3e2..0db04d6 100644 (file)
 
 #include <windows.h>
 
+/*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
-int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
+int WINAPI DllMain(HINSTANCE hInstance, DWORD reason, PVOID pvReserved)
 {
     switch (reason)
     {
index 06e524a..c62bb36 100644 (file)
  */
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 5706729..b345955 100644 (file)
@@ -96,6 +96,7 @@ Function::ReturnValue sci_getrelativefilename(types::typed_list &in, int _iRetCo
         FREE(wcsAbsFile);
 
         pStrOut->set(i, wcsResult);
+        FREE(wcsResult);
     }
 
     out.push_back(pStrOut);
index afbfd7d..b102736 100644 (file)
@@ -69,6 +69,8 @@ Function::ReturnValue sci_mget(typed_list &in, int _iRetCount, typed_list &out)
             Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), "mget", 2);
             return Function::Error;
         }
+
+        FREE(pstType);
         pstType = wide_string_to_UTF8(in[1]->getAs<types::String>()->get(0));
     }
 
@@ -90,6 +92,7 @@ Function::ReturnValue sci_mget(typed_list &in, int _iRetCount, typed_list &out)
     {
         case 0: // stderr
         case 6: // stdout
+            FREE(pstType);
             Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mget", iFile);
             return types::Function::Error;
     }
@@ -98,13 +101,14 @@ Function::ReturnValue sci_mget(typed_list &in, int _iRetCount, typed_list &out)
     // file opened with fortran open function
     if (pFile == NULL || pFile->getFileType() == 1)
     {
+        FREE(pstType);
         Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mget", iFile);
         return types::Function::Error;
     }
 
 
     C2F(mget)(&iFile, pData, &iSize, pstType, &iErr);
-
+    FREE(pstType);
     if (iErr > 0)
     {
         return Function::Error;
index 3e2af84..7885f8a 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 #pragma comment(lib,"../../bin/libxml2.lib")
 #pragma comment(lib,"../../bin/libcurl.lib")
index 599a076..bbcf78d 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index c710978..50c2b59 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 66ac267..d008a15 100644 (file)
@@ -81,7 +81,8 @@ GRAPHIC_OBJECTS_CXX_SOURCES = \
     src/cpp/createObjectData.cpp \
     src/cpp/pickSurface.cpp \
     src/cpp/Texture.cpp \
-    src/cpp/NormalGenerator.cpp
+    src/cpp/NormalGenerator.cpp \
+    src/cpp/DllmainGraphic_objects.cpp
 
 GIWS_WRAPPERS = \
     src/jni/graphic_objects.giws.xml \
index 6b6a86f..5df73f0 100644 (file)
@@ -233,7 +233,8 @@ am__objects_4 =  \
        src/cpp/libscigraphic_objects_la-createObjectData.lo \
        src/cpp/libscigraphic_objects_la-pickSurface.lo \
        src/cpp/libscigraphic_objects_la-Texture.lo \
-       src/cpp/libscigraphic_objects_la-NormalGenerator.lo
+       src/cpp/libscigraphic_objects_la-NormalGenerator.lo \
+       src/cpp/libscigraphic_objects_la-DllmainGraphic_objects.lo
 am_libscigraphic_objects_la_OBJECTS = $(am__objects_2) \
        $(am__objects_3) $(am__objects_4)
 libscigraphic_objects_la_OBJECTS =  \
@@ -753,7 +754,8 @@ GRAPHIC_OBJECTS_CXX_SOURCES = \
     src/cpp/createObjectData.cpp \
     src/cpp/pickSurface.cpp \
     src/cpp/Texture.cpp \
-    src/cpp/NormalGenerator.cpp
+    src/cpp/NormalGenerator.cpp \
+    src/cpp/DllmainGraphic_objects.cpp
 
 GIWS_WRAPPERS = \
     src/jni/graphic_objects.giws.xml \
@@ -1011,6 +1013,8 @@ src/cpp/libscigraphic_objects_la-Texture.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscigraphic_objects_la-NormalGenerator.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscigraphic_objects_la-DllmainGraphic_objects.lo:  \
+       src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 
 libscigraphic_objects.la: $(libscigraphic_objects_la_OBJECTS) $(libscigraphic_objects_la_DEPENDENCIES) $(EXTRA_libscigraphic_objects_la_DEPENDENCIES) 
        $(AM_V_CXXLD)$(libscigraphic_objects_la_LINK) $(am_libscigraphic_objects_la_rpath) $(libscigraphic_objects_la_OBJECTS) $(libscigraphic_objects_la_LIBADD) $(LIBS)
@@ -1035,6 +1039,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_objects_la-Data3D.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_objects_la-DataLoader.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_objects_la-DecompositionUtils.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_objects_la-DllmainGraphic_objects.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_objects_la-Fac3DColorComputer.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_objects_la-Fac3DDecomposer.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_objects_la-FigureList.Plo@am__quote@
@@ -1460,6 +1465,13 @@ src/cpp/libscigraphic_objects_la-NormalGenerator.lo: src/cpp/NormalGenerator.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscigraphic_objects_la-NormalGenerator.lo `test -f 'src/cpp/NormalGenerator.cpp' || echo '$(srcdir)/'`src/cpp/NormalGenerator.cpp
 
+src/cpp/libscigraphic_objects_la-DllmainGraphic_objects.lo: src/cpp/DllmainGraphic_objects.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscigraphic_objects_la-DllmainGraphic_objects.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscigraphic_objects_la-DllmainGraphic_objects.Tpo -c -o src/cpp/libscigraphic_objects_la-DllmainGraphic_objects.lo `test -f 'src/cpp/DllmainGraphic_objects.cpp' || echo '$(srcdir)/'`src/cpp/DllmainGraphic_objects.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscigraphic_objects_la-DllmainGraphic_objects.Tpo src/cpp/$(DEPDIR)/libscigraphic_objects_la-DllmainGraphic_objects.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/DllmainGraphic_objects.cpp' object='src/cpp/libscigraphic_objects_la-DllmainGraphic_objects.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscigraphic_objects_la-DllmainGraphic_objects.lo `test -f 'src/cpp/DllmainGraphic_objects.cpp' || echo '$(srcdir)/'`src/cpp/DllmainGraphic_objects.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index a5f9b13..59ac96a 100644 (file)
@@ -36,10 +36,7 @@ extern "C" {
 class DataModel
 {
 private :
-    DataModel()
-    {
-        m_dataMap = new std::map<int, Data3D*>();
-    }
+    DataModel() {}
 
 public :
     static DataModel *get()
@@ -52,6 +49,14 @@ public :
         return m_me;
     }
 
+    static void destroy()
+    {
+        if (m_me)
+        {
+            delete m_me;
+            m_me = NULL;
+        }
+    }
 public :
     /**
      * Sets a graphic object property
@@ -76,7 +81,7 @@ public :
 private :
     static DataModel *m_me;
 
-    std::map<int, Data3D*> *m_dataMap;
+    std::map<int, Data3D*> m_dataMap;
 };
 
 #endif
index 95809af..fd60e89 100644 (file)
     <ClCompile Include="..\cpp\CurrentFigure.cpp" />
     <ClCompile Include="..\cpp\CurrentObject.cpp" />
     <ClCompile Include="..\cpp\CurrentSubwin.cpp" />
+    <ClCompile Include="..\cpp\DllmainGraphic_objects.cpp" />
     <ClCompile Include="..\cpp\Fac3DColorComputer.cpp" />
     <ClCompile Include="..\cpp\FigureList.cpp" />
     <ClCompile Include="..\cpp\FigureModel.cpp" />
     <ClCompile Include="..\jni\ObjectData_wrap.c" />
     <ClCompile Include="..\jni\PolylineData_wrap.c" />
     <ClCompile Include="..\jni\ScilabNativeView_wrap.c" />
-    <ClCompile Include="DllmainGraphic_objects.c" />
     <ClCompile Include="..\cpp\Fac3DDecomposer.cpp" />
     <ClCompile Include="..\cpp\getGraphicObjectProperty.cpp" />
     <ClCompile Include="..\cpp\NgonData.cpp" />
index f9c15a2..80d2d8c 100644 (file)
@@ -50,9 +50,6 @@
     <ClCompile Include="..\cpp\deleteGraphicObject.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="DllmainGraphic_objects.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\cpp\Fac3DDecomposer.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\cpp\MeshFecDataDecomposer.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\cpp\DllmainGraphic_objects.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\jni\CallGraphicController.hxx">
diff --git a/scilab/modules/graphic_objects/src/cpp/DllmainGraphic_objects.cpp b/scilab/modules/graphic_objects/src/cpp/DllmainGraphic_objects.cpp
new file mode 100644 (file)
index 0000000..abf5264
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Allan CORNET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "DataModel.hxx"
+#ifdef _MSC_VER
+#include <windows.h>
+/*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+
+extern "C"
+{
+    int WINAPI DllMain(HINSTANCE hInstance, DWORD reason, PVOID pvReserved);
+}
+/*--------------------------------------------------------------------------*/
+#pragma comment(lib,"../../../../bin/libintl.lib")
+/*--------------------------------------------------------------------------*/
+int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
+{
+    switch (reason)
+    {
+        case DLL_PROCESS_ATTACH:
+            break;
+        case DLL_PROCESS_DETACH:
+            DataModel::destroy();
+            break;
+        case DLL_THREAD_ATTACH:
+            break;
+        case DLL_THREAD_DETACH:
+            break;
+    }
+    return 1;
+}
+#else
+__attribute__((constructor)) static void load(void);
+__attribute__((destructor)) static void unload(void);
+
+void load(void)
+{
+}
+
+void unload(void)
+{
+    DataModel::destroy();
+}
+#endif
+/*--------------------------------------------------------------------------*/
+
index 62da96c..cf4a8d8 100644 (file)
@@ -257,8 +257,16 @@ void ScilabView::deleteObject(int iUID)
 
     deleteDataObject(iUID);
 
-    m_pathList.erase(iUID);
+    /*clear userdata object*/
     m_userdata.erase(iUID);
+
+    //clear path object
+    __pathList_iterator itPath = m_pathList.find(iUID);
+    if (itPath != m_pathList.end())
+    {
+        delete itPath->second; //destroy PathItem object
+        m_pathList.erase(itPath); //remove entry
+    }
 }
 
 void ScilabView::updateObject(int iUID, int iProperty)
@@ -303,6 +311,7 @@ void ScilabView::updateObject(int iUID, int iProperty)
                     int* children = NULL;
                     getGraphicObjectProperty(iUID, __GO_CHILDREN__, jni_int_vector, (void**)&children);
                     item->children.assign(children, children + childrenCount);
+                    releaseGraphicObjectProperty(__GO_CHILDREN__, children, jni_int_vector, childrenCount);
                 }
             }
             break;
@@ -365,9 +374,6 @@ void ScilabView::updateObject(int iUID, int iProperty)
 void ScilabView::registerToController(void)
 {
     org_scilab_modules_graphic_objects::CallGraphicController::registerScilabView(getScilabJavaVM());
-    m_figureList.get_allocator().allocate(4096);
-    m_handleList.get_allocator().allocate(4096);
-    m_uidList.get_allocator().allocate(4096);
 }
 
 /*
@@ -717,15 +723,15 @@ int* ScilabView::getUserdata(int _id)
 /*
 ** Allocate static class variable.
 */
-ScilabView::__figureList ScilabView::m_figureList = *new __figureList();
-ScilabView::__handleList ScilabView::m_handleList = *new __handleList();
-ScilabView::__uidList ScilabView::m_uidList = *new __uidList();
+ScilabView::__figureList ScilabView::m_figureList;
+ScilabView::__handleList ScilabView::m_handleList;
+ScilabView::__uidList ScilabView::m_uidList;
 long ScilabView::m_topHandleValue = 0;
 int ScilabView::m_currentFigure;
 int ScilabView::m_currentObject;
 int ScilabView::m_currentSubWin;
 int ScilabView::m_figureModel;
 int ScilabView::m_axesModel;
-ScilabView::__pathList ScilabView::m_pathList = *new __pathList();
-ScilabView::__pathFigList ScilabView::m_pathFigList = *new __pathFigList();
-ScilabView::__userdata ScilabView::m_userdata = *new __userdata();
+ScilabView::__pathList ScilabView::m_pathList;
+ScilabView::__pathFigList ScilabView::m_pathFigList;
+ScilabView::__userdata ScilabView::m_userdata;
index 55317ad..92cdc49 100644 (file)
@@ -26,7 +26,7 @@ BOOL DataModel::setGraphicObjectProperty(int iUID, int _iName, void const* _dblV
     int property = 0;
     int returnValue = 0;
 
-    dataObject = (*m_dataMap)[iUID];
+    dataObject = m_dataMap[iUID];
     if (dataObject == NULL)
     {
         return FALSE;
@@ -49,7 +49,7 @@ void DataModel::getGraphicObjectProperty(int iUID, int _iName, void **_pvData)
     Data3D* dataObject = NULL;
     int property = 0;
 
-    dataObject = (*m_dataMap)[iUID];
+    dataObject = m_dataMap[iUID];
 
     if (dataObject == NULL)
     {
@@ -100,26 +100,26 @@ int DataModel::createDataObject(int iUID, int _iType)
             return 0;
     }
 
-    (*m_dataMap)[iUID] = newObject;
+    m_dataMap[iUID] = newObject;
 
     return iUID;
 }
 
 void DataModel::deleteDataObject(int iUID)
 {
-    std::map<int, Data3D*>::iterator it = m_dataMap->find(iUID);
-    if (it != m_dataMap->end() && it->second != NULL)
+    std::map<int, Data3D*>::iterator it = m_dataMap.find(iUID);
+    if (it != m_dataMap.end() && it->second != NULL)
     {
         delete it->second;
-        m_dataMap->erase(it);
+        m_dataMap.erase(it);
     }
 
-    /*Data3D* newObject = (*m_dataMap)[std::string(_pstID)];
+    /*Data3D* newObject = m_dataMap[std::string(_pstID)];
       if (newObject != NULL)
       {
       delete newObject;
       }
 
-      m_dataMap->erase(std::string(_pstID));*/
+      m_dataMap.erase(std::string(_pstID));*/
 }
 
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 7753e28..d7161de 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="..\c\DllmainGraphic_objects.c" />
+    <ClCompile Include="Dllmainnographic_objects.c" />
     <ClCompile Include="nographic_objects.c" />
   </ItemGroup>
   <ItemGroup>
index f67c2c2..36eb87d 100644 (file)
@@ -23,7 +23,7 @@
     <ClCompile Include="nographic_objects.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\c\DllmainGraphic_objects.c">
+    <ClCompile Include="Dllmainnographic_objects.c">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
index dbf6ee8..922ab55 100644 (file)
@@ -396,7 +396,8 @@ GRAPHICS_C_SOURCES = \
     src/c/getHandleProperty/set_auto_margins_property.c \
     src/c/getHandleProperty/get_auto_margins_property.c \
     src/c/name2rgb.c \
-    src/c/addColor.c
+    src/c/addColor.c \
+    src/c/DllmainGraphics.c
 
 GRAPHICS_CXX_SOURCES = \
     src/cpp/configgraphicvariable.cpp \
index 77996da..65bc701 100644 (file)
@@ -541,7 +541,8 @@ am__objects_1 = src/c/libscigraphics_algo_la-GetCommandArg.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-set_auto_margins_property.lo \
        src/c/getHandleProperty/libscigraphics_algo_la-get_auto_margins_property.lo \
        src/c/libscigraphics_algo_la-name2rgb.lo \
-       src/c/libscigraphics_algo_la-addColor.lo
+       src/c/libscigraphics_algo_la-addColor.lo \
+       src/c/libscigraphics_algo_la-DllmainGraphics.lo
 am__objects_2 =  \
        src/cpp/libscigraphics_algo_la-configgraphicvariable.lo \
        src/cpp/libscigraphics_algo_la-set_data_property.lo \
@@ -1384,7 +1385,8 @@ GRAPHICS_C_SOURCES = \
     src/c/getHandleProperty/set_auto_margins_property.c \
     src/c/getHandleProperty/get_auto_margins_property.c \
     src/c/name2rgb.c \
-    src/c/addColor.c
+    src/c/addColor.c \
+    src/c/DllmainGraphics.c
 
 GRAPHICS_CXX_SOURCES = \
     src/cpp/configgraphicvariable.cpp \
@@ -2815,6 +2817,8 @@ src/c/libscigraphics_algo_la-name2rgb.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libscigraphics_algo_la-addColor.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
+src/c/libscigraphics_algo_la-DllmainGraphics.lo:  \
+       src/c/$(am__dirstamp) src/c/$(DEPDIR)/$(am__dirstamp)
 src/cpp/$(am__dirstamp):
        @$(MKDIR_P) src/cpp
        @: > src/cpp/$(am__dirstamp)
@@ -3147,6 +3151,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-Contour.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-DefaultCommandArg.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-DestroyObjects.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-DllmainGraphics.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-DrawObjects.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-FeC.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscigraphics_algo_la-Format.Plo@am__quote@
@@ -6114,6 +6119,13 @@ src/c/libscigraphics_algo_la-addColor.lo: src/c/addColor.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscigraphics_algo_la-addColor.lo `test -f 'src/c/addColor.c' || echo '$(srcdir)/'`src/c/addColor.c
 
+src/c/libscigraphics_algo_la-DllmainGraphics.lo: src/c/DllmainGraphics.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libscigraphics_algo_la-DllmainGraphics.lo -MD -MP -MF src/c/$(DEPDIR)/libscigraphics_algo_la-DllmainGraphics.Tpo -c -o src/c/libscigraphics_algo_la-DllmainGraphics.lo `test -f 'src/c/DllmainGraphics.c' || echo '$(srcdir)/'`src/c/DllmainGraphics.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscigraphics_algo_la-DllmainGraphics.Tpo src/c/$(DEPDIR)/libscigraphics_algo_la-DllmainGraphics.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/DllmainGraphics.c' object='src/c/libscigraphics_algo_la-DllmainGraphics.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscigraphics_algo_la-DllmainGraphics.lo `test -f 'src/c/DllmainGraphics.c' || echo '$(srcdir)/'`src/c/DllmainGraphics.c
+
 src/nographics/libscigraphics_disable_la-nographics.lo: src/nographics/nographics.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphics_disable_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/nographics/libscigraphics_disable_la-nographics.lo -MD -MP -MF src/nographics/$(DEPDIR)/libscigraphics_disable_la-nographics.Tpo -c -o src/nographics/libscigraphics_disable_la-nographics.lo `test -f 'src/nographics/nographics.c' || echo '$(srcdir)/'`src/nographics/nographics.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/nographics/$(DEPDIR)/libscigraphics_disable_la-nographics.Tpo src/nographics/$(DEPDIR)/libscigraphics_disable_la-nographics.Plo
index ab3821d..fe947f1 100644 (file)
@@ -48,7 +48,6 @@ int sci_set(char *fname, void *pvApiCtx)
 
     int isMatrixOfString = 0;
 
-    char* pstProperty = NULL;
     char* pstNewProperty = NULL;
 
     unsigned long hdl;
@@ -111,6 +110,7 @@ int sci_set(char *fname, void *pvApiCtx)
         int iRows2 = 0;
         int iCols2 = 0;
         void* pvData = NULL;
+        char* pstProperty = NULL;
 
         if (isStringType(pvApiCtx, piAddr1) == 0)
         {
@@ -127,6 +127,7 @@ int sci_set(char *fname, void *pvApiCtx)
         sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstProperty);
             Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
             return 1;
         }
@@ -134,6 +135,7 @@ int sci_set(char *fname, void *pvApiCtx)
         sciErr = getVarType(pvApiCtx, piAddr2, &iType2);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstProperty);
             Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
             return 1;
         }
@@ -144,6 +146,7 @@ int sci_set(char *fname, void *pvApiCtx)
                 sciErr = getMatrixOfDouble(pvApiCtx, piAddr2, &iRows2, &iCols2, (double**)&pvData);
                 if (sciErr.iErr)
                 {
+                    freeAllocatedSingleString(pstProperty);
                     printError(&sciErr, 0);
                     Scierror(999, _("%s: Wrong type for input argument #%d: Matrix expected.\n"), fname, 2);
                     return sciErr.iErr;
@@ -153,6 +156,7 @@ int sci_set(char *fname, void *pvApiCtx)
                 sciErr = getMatrixOfHandle(pvApiCtx, piAddr2, &iRows2, &iCols2, (long long**)&pvData);
                 if (sciErr.iErr)
                 {
+                    freeAllocatedSingleString(pstProperty);
                     printError(&sciErr, 0);
                     Scierror(999, _("%s: Wrong type for input argument #%d: Matrix of handle expected.\n"), fname, 3);
                     return 1;
@@ -166,6 +170,7 @@ int sci_set(char *fname, void *pvApiCtx)
                     isMatrixOfString = 1;
                     if (getAllocatedMatrixOfString(pvApiCtx, piAddr2, &iRows2, &iCols2, (char***)&pvData))
                     {
+                        freeAllocatedSingleString(pstProperty);
                         Scierror(999, _("%s: Wrong size for input argument #%d: A matrix of string expected.\n"), fname, 2);
                         return 1;
                     }
@@ -174,6 +179,7 @@ int sci_set(char *fname, void *pvApiCtx)
                 {
                     if (getAllocatedSingleString(pvApiCtx, piAddr2, (char**)&pvData))
                     {
+                        freeAllocatedSingleString(pstProperty);
                         Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, 2);
                         return 1;
                     }
@@ -213,6 +219,7 @@ int sci_set(char *fname, void *pvApiCtx)
         }
         else
         {
+            freeAllocatedSingleString(pstProperty);
             Scierror(999, _("%s: Wrong value for input argument #%d: a valid property expected.\n"), fname, 1);
             if (iType2 == sci_strings)
             {
@@ -228,6 +235,7 @@ int sci_set(char *fname, void *pvApiCtx)
             return 0;
         }
 
+        freeAllocatedSingleString(pstProperty);
         AssignOutputVariable(pvApiCtx, 1) = 0;
         ReturnArguments(pvApiCtx);
         return 0;
@@ -305,6 +313,7 @@ int sci_set(char *fname, void *pvApiCtx)
         int iCols3 = 0;
         int iType3 = 0;
         void* pvData = NULL;
+        char* pstProperty = NULL;
 
         sciErr = getVarAddressFromPosition(pvApiCtx, iPos, &piAddr2);
         if (sciErr.iErr)
@@ -357,6 +366,7 @@ int sci_set(char *fname, void *pvApiCtx)
             sciErr = getVarType(pvApiCtx, piAddr3, &iType3);
             if (sciErr.iErr)
             {
+                freeAllocatedSingleString(pstProperty);
                 Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iPos + 1);
                 return 1;
             }
@@ -380,12 +390,14 @@ int sci_set(char *fname, void *pvApiCtx)
                     {
                         if (isScalar(pvApiCtx, piAddr3) == 0)
                         {
+                            freeAllocatedSingleString(pstProperty);
                             Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, iPos + 1);
                             return 1;
                         }
 
                         if (getAllocatedSingleString(pvApiCtx, piAddr3, (char**)&pvData))
                         {
+                            freeAllocatedSingleString(pstProperty);
                             Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iPos + 1);
                             return 1;
                         }
@@ -411,6 +423,7 @@ int sci_set(char *fname, void *pvApiCtx)
 
             if (sciErr.iErr)
             {
+                freeAllocatedSingleString(pstProperty);
                 Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iPos + 1);
                 return 1;
             }
@@ -429,9 +442,9 @@ int sci_set(char *fname, void *pvApiCtx)
                 freeAllocatedSingleString((char*)pvData);
             }
         }
-    }
 
-    freeAllocatedSingleString(pstProperty);
+        freeAllocatedSingleString(pstProperty);
+    }
 
     AssignOutputVariable(pvApiCtx, 1) = 0;
     ReturnArguments(pvApiCtx);
index 3982759..5287309 100644 (file)
  *
  */
 
+#include "SetHashTable.h"
+#include "GetHashTable.h"
+
+#ifdef _MSC_VER
+/*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
@@ -22,6 +31,8 @@ int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
         case DLL_PROCESS_ATTACH:
             break;
         case DLL_PROCESS_DETACH:
+            destroyScilabSetHashTable();
+            destroyScilabGetHashTable();
             break;
         case DLL_THREAD_ATTACH:
             break;
@@ -30,5 +41,15 @@ int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
     }
     return 1;
 }
+#else
+__attribute__((constructor)) static void load(void);
+__attribute__((destructor)) static void unload(void);
+
+void unload(void)
+{
+    destroyScilabSetHashTable();
+    destroyScilabGetHashTable();
+}
+#endif
 /*--------------------------------------------------------------------------*/
 
index 4a17106..e9b837b 100644 (file)
@@ -166,6 +166,7 @@ void InitFigureModel(int iFiguremdlUID)
     }
     // ColorMap
     setGraphicObjectProperty(iFiguremdlUID, __GO_COLORMAP__, pdblColorMap, jni_double_vector, 3 * m);
+    FREE(pdblColorMap);
 
     // Parent
     {
index 0b93958..b474e79 100644 (file)
@@ -627,6 +627,8 @@ BOOL update_specification_bounds(int iSubwinUID, double rect[6], int flag)
 
         rect[4] = dataBounds[4];
         rect[5] = dataBounds[5];
+
+        releaseGraphicObjectProperty(__GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6);
     }
 
     setGraphicObjectProperty(iSubwinUID, __GO_DATA_BOUNDS__, rect, jni_double_vector, 6);
index 20e2aad..1eff581 100644 (file)
@@ -68,8 +68,9 @@ int addColor(int _iFig, double* _pdblNewColor)
             pdblNewColorMap[i * (iColorMapSize + 1) + iColorMapSize] = _pdblNewColor[i];
         }
 
+        releaseGraphicObjectProperty(__GO_COLORMAP__, pdblColorMap, jni_double_vector, iColorMapSize * COLOR_COMPONENT);
         setGraphicObjectProperty(_iFig, __GO_COLORMAP__, pdblNewColorMap, jni_double_vector, iNewColorMapSize);
-
+        FREE(pdblNewColorMap);
         iColorIndex = iColorMapSize + 1;
     }
     return iColorIndex;
index e25f6c1..2c745aa 100644 (file)
@@ -38,6 +38,7 @@ void* get_position_property(void* _pvCtx, int iObjUID)
     int iType = -1;
     int* piType = &iType;
     double* position = NULL;
+    void* ret = NULL;
 
     getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **) &piType);
     if (piType == NULL)
@@ -112,6 +113,8 @@ void* get_position_property(void* _pvCtx, int iObjUID)
         return NULL;
     }
 
-    return sciReturnRowVector(position, 4);
+    ret = sciReturnRowVector(position, 4);
+    releaseGraphicObjectProperty(__GO_POSITION__, position, jni_double_vector, 4);
+    return ret;
 }
 /*------------------------------------------------------------------------*/
index d9d102f..4119de0 100644 (file)
@@ -466,6 +466,7 @@ int sci_figure(char * fname, void* pvApiCtx)
         {
             // Already set creating new figure
             // but let the set_ function fail if figure already exists
+            freeAllocatedSingleString(pstProName);
             continue;
         }
 
@@ -473,6 +474,7 @@ int sci_figure(char * fname, void* pvApiCtx)
         sciErr = getVarAddressFromPosition(pvApiCtx, i + 1, &piAddrData);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstProName);
             Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, i + 1);
             return 1;
         }
@@ -511,6 +513,7 @@ int sci_figure(char * fname, void* pvApiCtx)
                     {
                         if (getAllocatedSingleString(pvApiCtx, piAddrData, (char**)&_pvData))
                         {
+                            freeAllocatedSingleString(pstProName);
                             Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, 3);
                             return 1;
                         }
@@ -549,6 +552,7 @@ int sci_figure(char * fname, void* pvApiCtx)
             setGraphicObjectProperty(iAxes, __GO_BACKGROUND__, piBackground, jni_int, 1);
         }
 
+        freeAllocatedSingleString(pstProName);
         if (iType == sci_strings)
         {
             //free allacted data
@@ -584,6 +588,7 @@ int sci_figure(char * fname, void* pvApiCtx)
         int* piAxesSize = NULL;
         getGraphicObjectProperty(getFigureModel(), __GO_AXES_SIZE__, jni_int_vector, (void **)&piAxesSize);
         setGraphicObjectProperty(iFig, __GO_AXES_SIZE__, piAxesSize, jni_int_vector, 2);
+        releaseGraphicObjectProperty(__GO_AXES_SIZE__, piAxesSize, jni_int_vector, 2);
     }
 
     initBar(iFig, bMenuBar, bToolBar, bInfoBar);
index 9fa5aaf..efbf9de 100644 (file)
@@ -436,6 +436,8 @@ int sci_uicontrol(char *fname, void* pvApiCtx)
                     }
                 }
 
+                freeAllocatedSingleString(propertyName);
+
                 if (found == 0)
                 {
                     Scierror(999, _("%s: Unknown property: %s for '%s' handles.\n"), fname, propertyName, "Uicontrol");
@@ -509,7 +511,7 @@ int sci_uicontrol(char *fname, void* pvApiCtx)
                         if (iScroll)
                         {
                             freeAllocatedSingleString(styleProperty);
-                            styleProperty = strdup("framescrollable");
+                            styleProperty = os_strdup("framescrollable");
                         }
 
                         propertiesValuesIndices[scrollable_property] = NOT_FOUND;
@@ -679,6 +681,7 @@ int sci_uicontrol(char *fname, void* pvApiCtx)
 
         getGraphicObjectProperty(iUicontrol, __GO_POSITION__, jni_double_vector, (void**) &pdblPosition);
         setGraphicObjectProperty(iUicontrol, __GO_POSITION__, pdblPosition, jni_double_vector, 4);
+        releaseGraphicObjectProperty(__GO_POSITION__, pdblPosition, jni_double_vector, 4);
     }
 
     if ((nbInputArgument(pvApiCtx) < 2) || (propertiesValuesIndices[visible_property] == NOT_FOUND))    /* Visible property not set */
index 3c8401c..d48e6e5 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 998d857..e5cb285 100644 (file)
@@ -23,6 +23,7 @@ void* GetUicontrolString(void* _pvCtx, int iObjUID)
     int iNbStrings = 0;
     int *piNbStrings = &iNbStrings;
     char **pstString = NULL;
+    void* ret = NULL;
 
     getGraphicObjectProperty(iObjUID, __GO_UI_STRING_SIZE__, jni_int, (void **) &piNbStrings);
     getGraphicObjectProperty(iObjUID, __GO_UI_STRING_COLNB__, jni_int, (void **) &piNbColStrings);
@@ -31,16 +32,19 @@ void* GetUicontrolString(void* _pvCtx, int iObjUID)
     {
         if (iNbStrings == 0 || iNbColStrings == 0)
         {
-            return sciReturnEmptyMatrix();
+            ret = sciReturnEmptyMatrix();
         }
         else if (iNbColStrings == 1)
         {
-            return sciReturnStringMatrix(pstString, 1, iNbStrings);
+            ret = sciReturnStringMatrix(pstString, 1, iNbStrings);
         }
         else
         {
-            return sciReturnStringMatrix(pstString, iNbStrings / iNbColStrings, iNbColStrings);
+            ret = sciReturnStringMatrix(pstString, iNbStrings / iNbColStrings, iNbColStrings);
         }
+
+        releaseGraphicObjectProperty(__GO_UI_STRING__, pstString, jni_string_vector, iNbStrings);
+        return ret;
     }
     else
     {
index d289127..49c328e 100644 (file)
@@ -21,13 +21,16 @@ void* GetUicontrolTooltipString(void* _pvCtx, int iObjUID)
     int iNbStrings = 0;
     int *piNbStrings = &iNbStrings;
     char **pstString = NULL;
+    void* ret = NULL;
 
     getGraphicObjectProperty(iObjUID, __GO_UI_TOOLTIPSTRING_SIZE__, jni_int, (void **) &piNbStrings);
     getGraphicObjectProperty(iObjUID, __GO_UI_TOOLTIPSTRING__, jni_string_vector, (void **) &pstString);
 
     if (pstString != NULL)
     {
-        return sciReturnStringMatrix(pstString, 1, iNbStrings);
+        ret = sciReturnStringMatrix(pstString, 1, iNbStrings);
+        releaseGraphicObjectProperty(__GO_UI_TOOLTIPSTRING__, pstString, jni_string_vector, iNbStrings);
+        return ret;
     }
     else
     {
index d60a5d9..4cd8d86 100644 (file)
@@ -22,6 +22,7 @@ void* GetUicontrolUnits(void* _pvCtx, int iObjUID)
     char* units = NULL;
     int type = -1;
     int *piType = &type;
+    void* ret = NULL;
 
     /* Handle must be a uicontrol */
     getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void**) &piType);
@@ -32,5 +33,7 @@ void* GetUicontrolUnits(void* _pvCtx, int iObjUID)
     }
 
     getGraphicObjectProperty(iObjUID, __GO_UI_UNITS__, jni_string, (void**) &units);
-    return sciReturnString(units);
+    ret = sciReturnString(units);
+    releaseGraphicObjectProperty(__GO_UI_UNITS__, units, jni_string, 1);
+    return ret;
 }
index 8f5104c..13e5933 100644 (file)
 
 #ifdef _MSC_VER
 #include <windows.h>
-
+/*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
 /*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 #pragma comment(lib,"../../../../bin/hdf5dll.lib")
index d9be569..63387f5 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 8996783..d16421c 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 493d63b..684889d 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 13dbd6e..71c64e5 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index c852b4f..8e56143 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index a51c9e3..ef4f456 100644 (file)
@@ -20,7 +20,6 @@
 #include "getenvc.h"
 #include "PATH_MAX.h"
 #include "api_scilab.h"
-#include "getenvc.h"
 /*--------------------------------------------------------------------------*/
 int sci_getenv(char *fname, void* pvApiCtx)
 {
@@ -37,12 +36,12 @@ int sci_getenv(char *fname, void* pvApiCtx)
 
     int iflag = 0;
 
-    Rhs = Max(Rhs, 0);
+    int iRhs = nbInputArgument(pvApiCtx);
 
     CheckRhs(1, 2);
     CheckLhs(1, 1);
 
-    if (Rhs == 2)
+    if (iRhs == 2)
     {
         sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
         if (sciErr.iErr)
@@ -105,7 +104,7 @@ int sci_getenv(char *fname, void* pvApiCtx)
     {
         if (pStVarTwo)
         {
-            if (createSingleString(pvApiCtx, Rhs + 1, pStVarTwo))
+            if (createSingleString(pvApiCtx, iRhs + 1, pStVarTwo))
             {
                 freeAllocatedSingleString(pStVarOne);
                 freeAllocatedSingleString(pStVarTwo);
@@ -116,8 +115,8 @@ int sci_getenv(char *fname, void* pvApiCtx)
             {
                 freeAllocatedSingleString(pStVarOne);
                 freeAllocatedSingleString(pStVarTwo);
-                LhsVar(1) = Rhs + 1;
-                PutLhsVar();
+                LhsVar(1) = iRhs + 1;
+                ReturnArguments(pvApiCtx);
                 return 0;
             }
         }
@@ -144,7 +143,7 @@ int sci_getenv(char *fname, void* pvApiCtx)
     freeAllocatedSingleString(pStVarOne);
 
     //create variable on stack and return it.
-    if (createSingleString(pvApiCtx, Rhs + 1, env_value))
+    if (createSingleString(pvApiCtx, iRhs + 1, env_value))
     {
         FREE(env_value);
         printError(&sciErr, 0);
@@ -153,8 +152,8 @@ int sci_getenv(char *fname, void* pvApiCtx)
     }
 
     FREE(env_value);
-    LhsVar(1) = Rhs + 1;
-    PutLhsVar();
+    AssignOutputVariable(pvApiCtx, 1) = iRhs + 1;
+    ReturnArguments(pvApiCtx);
 
 
     return 0;
index c86b5b0..6bf839f 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 47437b0..0643f07 100644 (file)
@@ -62,6 +62,7 @@ void getenvc(int *ierr, const char *var, char *buf, int *buflen, int *iflag)
                 sciprint(_("Undefined environment variable %s.\n"), var);
             }
 
+            FREE(wbuf);
             FREE(wvar);
             *ierr = 1;
             return;
index 4b23d91..336a3d4 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index ddbb058..ad5f033 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libxml2.lib")
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
index 0911009..8cc312d 100644 (file)
@@ -46,6 +46,8 @@ static void freeJavaVMOption(void)
             }
         }
         nOptions = 0;
+        FREE(jvm_options);
+        jvm_options = NULL;
     }
 }
 
@@ -246,6 +248,8 @@ BOOL startJVM(char *SCI_PATH)
                         {
                             fprintf(stderr, "%d: %s\n", j, vm_args.options[j].optionString);
                         }
+
+                        freeJavaVMOption();
                     }
                     return FALSE;
                 }
@@ -267,10 +271,9 @@ BOOL startJVM(char *SCI_PATH)
         freeJavaVMOption();
         return FALSE;
     }
-    else
-    {
-        return TRUE;
-    }
+
+    freeJavaVMOption();
+    return TRUE;
 }
 /*--------------------------------------------------------------------------*/
 BOOL finishJVM(void)
index b4e9187..17e3dc0 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 #pragma comment(lib,"../../../../bin/blasplus.lib")
 #pragma comment(lib,"../../../../bin/lapack.lib")
index ffa6e03..849def3 100644 (file)
@@ -280,6 +280,7 @@ int iEigen1RealM(double* pData, int iCols, double* pEigenValuesReal, double* pEi
         pWork = allocWorkspace(ws, 0, &worksize);
         pRightVectors =  (lhs == 2 ? (double*)MALLOC(iCols * iCols * sizeof(double)) : NULL );
         iEigen1R(pData, iCols, pEigenValuesReal, pEigenValuesImg, pRightVectors, pWork, worksize);
+        FREE(pWork);
         if (lhs == 2)
         {
             assembleEigenvectorsSourceToTarget(iCols, pEigenValuesImg,
index 3a3febe..1f966e7 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index ce0916b..5d45e8e 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 #pragma comment(lib,"../../bin/libmatio.lib")
 /*--------------------------------------------------------------------------*/
index f65a5da..59f39a6 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 #pragma comment(lib,"../../bin/blasplus.lib")
 
 //MS MPI
 #pragma comment(lib,"../../libs/mpi/lib/msmpi.lib")
 
-
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
 {
index 89abc60..d9c4a18 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 #pragma comment(lib,"../../../../bin/blasplus.lib")
 #pragma comment(lib,"../../../../bin/lapack.lib")
index 4662cee..ebeb90b 100644 (file)
  */
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index c130af3..d2822b2 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 #ifdef __INTEL_COMPILER
 #pragma comment(lib,"libiomp5md.lib")
index 96bd1e0..2125b2a 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 0c6b0b7..f8749d3 100644 (file)
@@ -239,6 +239,7 @@ types::Function::ReturnValue sci_roots(types::typed_list &in, int _iRetCount, ty
         memset(pdblOutReal, 0x00, pDblOut->getSize() * sizeof(double));
         C2F(dset)(&iSizeM1, &dblOne, &pdblOutReal[iSize], &iSizeP1);
         C2F(dcopy)(&iSize, pdblTempReal, &iOne, pdblOutReal, &iOne);
+        delete[] pdblTempReal;
 
         if (bComplex)
         {
index 0b8f11d..0fe8260 100644 (file)
 #include <windows.h>
 #include "machine.h"
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 /* COMMON used by fortran */
index 5010db4..3e5d5f2 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 #pragma comment(lib, "../../../../bin/libxml2.lib")
 /*--------------------------------------------------------------------------*/
index d3d8175..66902ca 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index fd2dc17..a2bfca2 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 87ca713..d32a905 100644 (file)
@@ -4,6 +4,11 @@
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
 {
     switch (reason)
index 98eee28..f5c458a 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
 {
     switch (reason)
index 8996783..d16421c 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 2c6b605..53267d0 100644 (file)
 #include <windows.h>
 #include "machine.h" /* C2F */
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 /* defines & exports fortran COMMON in C */
index 65d317a..e124927 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index d3d8175..66902ca 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 3fa5526..b804cd9 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 29f2a41..ee62564 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index b8afdb6..c922a27 100644 (file)
  */
 
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
index db56eca..bb5d499 100644 (file)
@@ -168,6 +168,14 @@ Double* StringToDouble(String* _pst)
 
     if (iTotalLen == 0)
     {
+        for (int i = 0; i < iSize; ++i)
+        {
+            if (pst[i])
+            {
+                FREE(pst[i]);
+            }
+        }
+
         delete[] pst;
         delete[] pstLen;
         return Double::Empty();
@@ -186,6 +194,7 @@ Double* StringToDouble(String* _pst)
             //transform character value as double.
             pdbl[index] = (unsigned char)pst[i][j];
         }
+        FREE(pst[i]);
     }
 
     delete[] pstLen;
index 85c3445..4bf93b5 100644 (file)
@@ -145,6 +145,18 @@ Function::ReturnValue sci_grep(typed_list &in, int _iRetCount, typed_list &out)
         code_error_grep = GREP_OLD(&grepresults, pStr1, pS1->getSize(), pStr2, pS2->getSize());
     }
 
+    for (int i = 0; i < pS1->getSize(); i++)
+    {
+        FREE(pStr1[i]);
+    }
+    FREE(pStr1);
+
+    for (int i = 0; i < pS2->getSize(); i++)
+    {
+        FREE(pStr2[i]);
+    }
+    FREE(pStr2);
+
     switch (code_error_grep)
     {
         case GREP_OK :
@@ -201,7 +213,7 @@ Function::ReturnValue sci_grep(typed_list &in, int _iRetCount, typed_list &out)
 
         case MEMORY_ALLOC_ERROR :
             Scierror(999, _("%s: No more memory.\n"), "grep");
-            //no break, to free reserved memory.
+        //no break, to free reserved memory.
         case GREP_ERROR :
         {
             if (grepresults.values)
@@ -219,18 +231,6 @@ Function::ReturnValue sci_grep(typed_list &in, int _iRetCount, typed_list &out)
         break;
     }
 
-    for (int i = 0 ; i < pS1->getSize() ; i++)
-    {
-        FREE(pStr1[i]);
-    }
-    FREE(pStr1);
-
-    for (int i = 0 ; i < pS2->getSize() ; i++)
-    {
-        FREE(pStr2[i]);
-    }
-    FREE(pStr2);
-
     return Function::OK;
 }
 //Function::ReturnValue sci_grep(typed_list &in, int _iRetCount, typed_list &out)
index dd7bb88..48ecef4 100644 (file)
@@ -67,6 +67,7 @@ types::Function::ReturnValue sci_isalphanum(types::typed_list &in, int _iRetCoun
 
     pBOut = new types::Bool(1, iResultSize);
     pBOut->set(pbResult);
+    FREE(pbResult);
     out.push_back(pBOut);
 
     return types::Function::OK;
index 24daf61..f3d2d04 100644 (file)
@@ -66,6 +66,7 @@ types::Function::ReturnValue sci_isascii(types::typed_list &in, int _iRetCount,
 
         pBOut = new types::Bool(1, iResultSize);
         pBOut->set(pbResult);
+        FREE(pbResult);
         out.push_back(pBOut);
     }
     else if (in[0]->isDouble())
@@ -80,6 +81,7 @@ types::Function::ReturnValue sci_isascii(types::typed_list &in, int _iRetCount,
 
         pBOut = new types::Bool(1, pIn->getSize());
         pBOut->set(pbResult);
+        FREE(pbResult);
         out.push_back(pBOut);
     }
     else
index 26cdf19..e8ae05f 100644 (file)
@@ -67,6 +67,7 @@ types::Function::ReturnValue sci_isdigit(types::typed_list &in, int _iRetCount,
 
     pBOut = new types::Bool(1, iResultSize);
     pBOut->set(pbResult);
+    FREE(pbResult);
     out.push_back(pBOut);
 
     return types::Function::OK;
index 6f3c2fe..cf3fa13 100644 (file)
@@ -78,6 +78,10 @@ types::Function::ReturnValue sci_isletter(types::typed_list &in, int _iRetCount,
         out.push_back(types::Double::Empty());
     }
 
+    if (values)
+    {
+        FREE(values);
+    }
     return types::Function::OK;
 }
 
index 03f57d3..f1675d7 100644 (file)
@@ -148,6 +148,13 @@ Function::ReturnValue sci_regexp(typed_list &in, int _iRetCount, typed_list &out
             pcre_error("regexp", iPcreStatus);
             delete[] piStart;
             delete[] piEnd;
+            for (int i = 0; i < iOccurs; i++)
+            {
+                freeArrayOfWideString(pwstCapturedString[i], piCapturedStringCount[i]);
+            }
+
+            FREE(pwstCapturedString);
+            FREE(piCapturedStringCount);
             return Function::Error;
         }
     }
@@ -171,6 +178,8 @@ Function::ReturnValue sci_regexp(typed_list &in, int _iRetCount, typed_list &out
             out.push_back(new String(L""));
         }
 
+        FREE(pwstCapturedString);
+        FREE(piCapturedStringCount);
         delete[] piStart;
         delete[] piEnd;
         return Function::OK;
@@ -258,15 +267,15 @@ Function::ReturnValue sci_regexp(typed_list &in, int _iRetCount, typed_list &out
         }
         out.push_back(pS);
 
-        for (int i = 0 ; i < iOccurs ; i++)
-        {
-            freeArrayOfWideString(pwstCapturedString[i], piCapturedStringCount[i]);
-        }
+    }
 
-        FREE(pwstCapturedString);
-        FREE(piCapturedStringCount);
+    for (int i = 0; i < iOccurs; i++)
+    {
+        freeArrayOfWideString(pwstCapturedString[i], piCapturedStringCount[i]);
     }
 
+    FREE(pwstCapturedString);
+    FREE(piCapturedStringCount);
     delete[] piStart;
     delete[] piEnd;
     return Function::OK;
index 6d17b34..9e908f7 100644 (file)
@@ -175,6 +175,7 @@ Function::ReturnValue sci_strcat(typed_list &in, int _iRetCount, typed_list &out
                     wcscat(pwstOut + iOffset, pS->get(j, i));
                 }
                 pOut->set(0, i, pwstOut);
+                FREE(pwstOut);
             }
             break;
         }
@@ -208,562 +209,13 @@ Function::ReturnValue sci_strcat(typed_list &in, int _iRetCount, typed_list &out
                     wcscat(pwstOut + iOffset, pS->get(i, j));
                 }
                 pOut->set(i, 0, pwstOut);
+                FREE(pwstOut);
             }
             break;
         }
     }
 
-
     out.push_back(pOut);
     return Function::OK;
-    //    CheckRhs(1,3);
-    //    CheckLhs(1,1);
-    //
-    //    switch (Rhs)
-    //    {
-    //    case 3:
-    //        {
-    //            sci_strcat_three_rhs(fname);
-    //        }
-    //        break;
-    //    case 2:
-    //        {
-    //            sci_strcat_two_rhs(fname);
-    //        }
-    //        break;
-    //    case 1:
-    //        {
-    //            sci_strcat_one_rhs(fname);
-    //        }
-    //        break;
-    //    default:
-    //        /* nothing */
-    //        break;
-    //    }
-    //    return 0;
-    //}
-    ///*-------------------------------------------------------------------------------------*/
-    //static int sci_strcat_three_rhs(char *fname)
-    //{
-    //    int Row_One = 0,Col_One = 0;
-    //    char **Input_String_One = NULL;
-    //    int mn = 0;
-    //    static char def_sep[] = "";
-    //    char *Input_String_Two = def_sep;
-    //    char typ = 0;
-    //    int i = 0;
-    //
-    //    if (VarType(1) != sci_strings)
-    //    {
-    //        Scierror(999,_("%s: Wrong type for input argument #%d: a string vector expected.\n"),fname,1);
-    //        return 0;
-    //    }
-    //
-    //    if (VarType(2) != sci_strings)
-    //    {
-    //        Scierror(999,"%s : Wrong size for input argument #%d: Single string expected.\n",fname,2);
-    //        return 0;
-    //    }
-    //
-    //    if (VarType(3) != sci_strings)
-    //    {
-    //        Scierror(999,"%s : Wrong size for input argument #%d: Single string expected.\n",fname,3);
-    //        return 0;
-    //    }
-    //
-    //    GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&Row_One,&Col_One,&Input_String_One);
-    //    mn = Row_One * Col_One;
-    //
-    //    if (Rhs >= 2)
-    //    {
-    //        /* second argument always a string and not a matrix of string */
-    //        int l2 = 0;
-    //        int Row_Two = 0,Col_Two = 0;
-    //        GetRhsVar(2, STRING_DATATYPE, &Row_Two, &Col_Two, &l2);
-    //        Input_String_Two = cstk(l2);
-    //    }
-    //
-    //    if (Rhs >= 3)
-    //    {
-    //        int Row_Three = 0, Col_Three = 0;
-    //        int l3 = 0;
-    //        GetRhsVar(3, STRING_DATATYPE, &Row_Three, &Col_Three, &l3);
-    //        if (Row_Three * Col_Three != 0) typ = cstk(l3)[0];
-    //        if (typ != COL && typ != ROW )
-    //        {
-    //            freeArrayOfString(Input_String_One,mn);
-    //            Scierror(999,_("%s: Wrong type for input argument #%d: ''%s'' or ''%s'' expected.\n"),fname,3,"c","r");
-    //            return 0;
-    //        }
-    //    }
-    //
-    //    switch ( typ )
-    //    {
-    //    case STAR :
-    //        {
-    //            int nchars = 0;
-    //            int one = 1;
-    //            int l3 = 0;
-    //            int k = 0;
-    //
-    //            /* just return one string */
-    //            for ( i = 0 ; i < mn ; i++ ) nchars += (int)strlen(Input_String_One[i]);
-    //            nchars += (mn-1)*(int)strlen(Input_String_Two);
-    //
-    //            CreateVar(Rhs+1,STRING_DATATYPE,&one,&nchars,&l3);
-    //
-    //            for ( i = 0 ; i < mn ; i++ )
-    //            {
-    //                int j = 0;
-    //                for ( j =0 ; j < (int)strlen(Input_String_One[i]) ; j++ ) *cstk(l3+ k++) = Input_String_One[i][j];
-    //                if ( i != mn-1) for ( j =0 ; j < (int)strlen(Input_String_Two) ; j++ ) *cstk(l3+ k++) = Input_String_Two[j];
-    //            }
-    //            freeArrayOfString(Input_String_One,mn);
-    //            LhsVar(1) = Rhs+1  ;
-    //        }
-    //        break;
-    //    case COL:
-    //        {
-    //            char **Output_String = NULL;
-    //            int nchars = 0;
-    //            int one = 1;
-    //            /* return a column matrix */
-    //            if ( (Output_String = (char**)MALLOC((Row_One+1)*sizeof(char *)))==NULL)
-    //            {
-    //                freeArrayOfString(Input_String_One,mn);
-    //                Scierror(999,_("%s: No more memory.\n"),fname);
-    //                return 0;
-    //            }
-    //            Output_String[Row_One]=NULL;
-    //            for (i= 0 ; i < Row_One ; i++)
-    //            {
-    //                int j = 0;
-    //                /* length of row i */
-    //                nchars = 0;
-    //                for ( j = 0 ; j < Col_One ; j++ ) nchars += (int)strlen(Input_String_One[i+ Row_One*j]);
-    //                nchars += (Col_One-1)*(int)strlen(Input_String_Two);
-    //
-    //                Output_String[i]=(char*)MALLOC((nchars+1)*sizeof(char));
-    //                if ( Output_String[i] == NULL)
-    //                {
-    //                    freeArrayOfString(Output_String,i);
-    //                    freeArrayOfString(Input_String_One,mn);
-    //                    Scierror(999,_("%s: No more memory.\n"),fname);
-    //                    return 0;
-    //                }
-    //                /* fill the string */
-    //                strcpy(Output_String[i],Input_String_One[i]);
-    //
-    //                for ( j = 1 ; j < Col_One ; j++ )
-    //                {
-    //                    strcat(Output_String[i],Input_String_Two);
-    //                    strcat(Output_String[i],Input_String_One[i+ Row_One*j]);
-    //                }
-    //            }
-    //
-    //            CreateVarFromPtr(Rhs+1,MATRIX_OF_STRING_DATATYPE, &Row_One, &one, Output_String);
-    //            freeArrayOfString(Input_String_One,mn);
-    //            freeArrayOfString(Output_String,Row_One+1);
-    //            LhsVar(1) = Rhs+1  ;
-    //        }
-    //        break;
-    //
-    //    case ROW:
-    //        {
-    //            int nchars = 0;
-    //            int j = 0;
-    //            int one = 1;
-    //            char **Output_String = (char **)CALLOC(Col_One, sizeof(char*));
-    //
-    //            /* return a row matrix */
-    //            if (Output_String == NULL)
-    //            {
-    //                freeArrayOfString(Input_String_One, mn);
-    //                Scierror(999,_("%s: No more memory.\n"), fname);
-    //                return 0;
-    //            }
-    //
-    //            for (j = 0 ; j < Col_One ; j++)
-    //            {
-    //                Output_String[j] = os_strdup(Input_String_One[j*Row_One]);
-    //
-    //                if ( Output_String[j] == NULL)
-    //                {
-    //                    freeArrayOfString(Output_String,j);
-    //                    freeArrayOfString(Input_String_One, mn);
-    //                    Scierror(999,_("%s: No more memory.\n"), fname);
-    //                    return 0;
-    //                }
-    //
-    //                for ( i = 1 ; i < Row_One ; i++ )
-    //                {
-    //                    int lenOutput = 0;
-    //                    int lenInput = 0;
-    //                    int lenNew = 0;
-    //
-    //                    if (Input_String_Two)
-    //                    {
-    //                        lenOutput = (int)strlen(Output_String[j]);
-    //                        lenInput = (int)strlen(Input_String_Two);
-    //                        lenNew = lenOutput + lenInput + 1;
-    //
-    //                        Output_String[j] = (char*)REALLOC(Output_String[j], sizeof(char*) * lenNew);
-    //                        if (Output_String[j] == NULL)
-    //                        {
-    //                            freeArrayOfString(Output_String,j);
-    //                            freeArrayOfString(Input_String_One, mn);
-    //                            Scierror(999,_("%s: No more memory.\n"), fname);
-    //                            return 0;
-    //                        }
-    //                        strcat(Output_String[j], Input_String_Two);
-    //                    }
-    //
-    //                    if (Input_String_One[i+ Row_One*j])
-    //                    {
-    //                        lenOutput = (int)strlen(Output_String[j]);
-    //                        lenInput = (int)strlen(Input_String_One[i+ Row_One*j]);
-    //                        lenNew = lenOutput + lenInput + 1;
-    //
-    //                        Output_String[j] = (char*)REALLOC(Output_String[j], sizeof(char*) * lenNew);
-    //                        if (Output_String[j] == NULL)
-    //                        {
-    //                            freeArrayOfString(Output_String,j);
-    //                            freeArrayOfString(Input_String_One, mn);
-    //                            Scierror(999,_("%s: No more memory.\n"), fname);
-    //                            return 0;
-    //                        }
-    //                        strcat(Output_String[j], Input_String_One[i+ Row_One*j]);
-    //                    }
-    //                }
-    //            }
-    //
-    //            CreateVarFromPtr(Rhs+1,MATRIX_OF_STRING_DATATYPE, &one, &Col_One, Output_String);
-    //            freeArrayOfString(Input_String_One, mn);
-    //            if (Col_One == 1)
-    //            {
-    //                FREE(Output_String);
-    //                Output_String = NULL;
-    //            }
-    //            else
-    //            {
-    //                freeArrayOfString(Output_String, Col_One);
-    //            }
-    //            LhsVar(1) = Rhs+1  ;
-    //        }
-    //        break;
-    //
-    //    default:
-    //        {
-    //            freeArrayOfString(Input_String_One,mn);
-    //            Scierror(999,_("%s: Wrong value for input argument #%d: ''%s'' or ''%s'' expected.\n"),fname,3,"c","r");
-    //            return 0;
-    //        }
-    //        break;
-    //
-    //    }
-    //    C2F(putlhsvar)();
-    //    return 0;
-    //}
-    ///*-------------------------------------------------------------------------------------*/
-    //static int sci_strcat_two_rhs(char *fname)
-    //{
-    //    int Type_One = VarType(1);
-    //    int Type_Two = VarType(2);
-    //
-    //    int Number_Inputs_Two = 0;
-    //    char **Input_String_Two = NULL;
-    //
-    //    if (Type_Two != sci_strings)
-    //    {
-    //        Scierror(246,_("%s: Wrong type for input argument #%d: Single string expected.\n"),fname,2);
-    //        return 0;
-    //    }
-    //    else /* sci_strings */
-    //    {
-    //        int Row_Two = 0,Col_Two = 0;
-    //
-    //        GetRhsVar(2,MATRIX_OF_STRING_DATATYPE,&Row_Two,&Col_Two,&Input_String_Two);
-    //        Number_Inputs_Two = Row_Two * Col_Two;
-    //        /* check we have only a string as second parameter */
-    //        if (Number_Inputs_Two != 1)
-    //        {
-    //            freeArrayOfString(Input_String_Two,Number_Inputs_Two);
-    //            Scierror(36,"%s : Wrong size for input argument #%d: Single string expected.\n",fname,2);
-    //            return 0;
-    //        }
-    //    }
-    //
-    //    if ( (Type_One != sci_strings) && (Type_One != sci_matrix) )
-    //    {
-    //        freeArrayOfString(Input_String_Two,Number_Inputs_Two);
-    //        Scierror(246,"%s: Wrong type for input argument #%d: Matrix of strings expected.\n",fname,1);
-    //        return 0;
-    //    }
-    //    else
-    //    {
-    //        if (Type_One == sci_matrix)
-    //        {
-    //            freeArrayOfString(Input_String_Two,Number_Inputs_Two);
-    //            sci_strcat_rhs_one_is_a_matrix(fname);
-    //        }
-    //        else /* sci_strings */
-    //        {
-    //            char **Input_String_One = NULL;
-    //            int Row_One = 0,Col_One = 0;
-    //            int Number_Inputs_One = 0;
-    //            int length_output = 0;
-    //
-    //            GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&Row_One,&Col_One,&Input_String_One);
-    //            Number_Inputs_One = Row_One * Col_One;
-    //
-    //            if (Input_String_One)
-    //            {
-    //                if ( (Number_Inputs_One == 1) && (strcmp(Input_String_One[0],"")==0) )
-    //                {
-    //                    /* With no input argument returns a zero length character string */
-    //                    int m1 = 0, n1 = 0, l1 = 0;
-    //
-    //                    CreateVar(Rhs+1,STRING_DATATYPE,  &m1, &n1, &l1);
-    //                    LhsVar(1)=Rhs+1;
-    //                    C2F(putlhsvar)();
-    //
-    //                    freeArrayOfString(Input_String_Two,Number_Inputs_Two);
-    //                    freeArrayOfString(Input_String_One,Number_Inputs_One);
-    //                    return 0;
-    //                }
-    //                else
-    //                {
-    //                    if (Number_Inputs_One == 1)
-    //                    {
-    //                        length_output = (int)strlen(Input_String_One[0]);
-    //                    }
-    //                    else
-    //                    {
-    //                        int lengthInput_String_Two = (int)strlen(Input_String_Two[0]);
-    //                        length_output = sumlengthstring(1) + (int)(Number_Inputs_One)*lengthInput_String_Two - lengthInput_String_Two;
-    //                    }
-    //                }
-    //            }
-    //
-    //            if (length_output > 0)
-    //            {
-    //                static int n1 = 0, m1 = 0;
-    //                int outIndex = 0 ;
-    //                char *Output_String = NULL;
-    //                int i = 0;
-    //                int Number_Inputs_OneLessOne = Number_Inputs_One - 1;
-    //
-    //                m1 = length_output;
-    //                n1 = 1;
-    //
-    //                CreateVar( Rhs+1,STRING_DATATYPE,&m1,&n1,&outIndex);
-    //                Output_String = cstk(outIndex);
-    //
-    //                /* strcpy + strcat faster than sprintf */
-    //                strcpy(Output_String,Input_String_One[0]);
-    //                ( 0 < Number_Inputs_OneLessOne )? strcat(Output_String,Input_String_Two[0]):0;
-    //
-    //                for (i = 1; i < Number_Inputs_One; i++)
-    //                {
-    //                    strcat(Output_String,Input_String_One[i]);
-    //                    ( i < Number_Inputs_OneLessOne )? strcat(Output_String,Input_String_Two[0]):0;
-    //                }
-    //
-    //                LhsVar(1) = Rhs+1;
-    //                C2F(putlhsvar)();
-    //                freeArrayOfString(Input_String_One,Row_One*Col_One);
-    //                freeArrayOfString(Input_String_Two,Number_Inputs_Two);
-    //            }
-    //            else
-    //            {
-    //                if (length_output == 0)
-    //                {
-    //                    int one    = 1 ;
-    //                    int len   = (int)strlen(EMPTY_CHAR);
-    //                    int outIndex = 0 ;
-    //
-    //                    CreateVar(Rhs+1,STRING_DATATYPE,&len,&one,&outIndex);
-    //                    strcpy(cstk(outIndex),EMPTY_CHAR);
-    //                    LhsVar(1) = Rhs+1 ;
-    //                    C2F(putlhsvar)();
-    //
-    //                    freeArrayOfString(Input_String_Two,Number_Inputs_Two);
-    //                    freeArrayOfString(Input_String_One,Number_Inputs_One);
-    //                }
-    //                else
-    //                {
-    //                    freeArrayOfString(Input_String_Two,Number_Inputs_Two);
-    //                    freeArrayOfString(Input_String_One,Number_Inputs_One);
-    //                    Scierror(999,_("%s : Wrong size for input argument(s).\n"),fname);
-    //                }
-    //            }
-    //        }
-    //    }
-    //    return 0;
-    //}
-    ///*-------------------------------------------------------------------------------------*/
-    //static int sci_strcat_one_rhs(char *fname)
-    //{
-    //    int Type_One = VarType(1);
-    //    if ( (Type_One != sci_strings) && (Type_One != sci_matrix) )
-    //    {
-    //        Scierror(246,"%s: Wrong type for input argument #%d: Matrix of strings expected.\n",fname,1);
-    //        return 0;
-    //    }
-    //    else
-    //    {
-    //        if (Type_One == sci_strings)
-    //        {
-    //            int lenstrcat =  sumlengthstring(1);
-    //
-    //            if (lenstrcat >= 0)
-    //            {
-    //                char **Input_String_One = NULL;
-    //                int m = 0, n = 0; /* matrix size */
-    //                int mn = 0; /* m*n */
-    //                int n1 = 1, m1 = lenstrcat;
-    //                int outIndex = 0 ;
-    //
-    //                char *Output_String = NULL;
-    //                int i = 0;
-    //
-    //                int sizeLengths = 0;
-    //                int *lengths = lengthEachString(1, &sizeLengths);
-    //
-    //                int l = 0;
-    //
-    //                if (lengths == NULL)
-    //                {
-    //                    Scierror(999,_("%s: error.\n"),fname);
-    //                    return 0;
-    //                }
-    //
-    //                GetRhsVar(1,MATRIX_OF_STRING_DATATYPE,&m,&n,&Input_String_One);
-    //                mn = m * n;
-    //
-    //                CreateVar( Rhs+1,STRING_DATATYPE,&m1,&n1,&outIndex);
-    //                Output_String = cstk(outIndex);
-    //
-    //                l = 0;
-    //                for (i = 0; i < mn; i++)
-    //                {
-    //                    /* bug 4728 Compatibility with Scilab 4.1.2 */
-    //                    /* replaces strcpy & strcat by memcpy */
-    //                    /* copy of char array and not string */
-    //                    if ( i == 0)
-    //                    {
-    //                        memcpy(Output_String,Input_String_One[i], lengths[i]);
-    //                    }
-    //                    else
-    //                    {
-    //                        memcpy(Output_String + l, Input_String_One[i],  lengths[i]);
-    //                    }
-    //                    l = l + lengths[i];
-    //                }
-    //
-    //                FREE(lengths); lengths = NULL;
-    //
-    //                LhsVar(1) = Rhs+1;
-    //                C2F(putlhsvar)();
-    //                if (Input_String_One) freeArrayOfString(Input_String_One,mn);
-    //            }
-    //            else
-    //            {
-    //                Scierror(999,_("%s: Wrong size for input argument(s).\n"),fname);
-    //            }
-    //        }
-    //        else /* sci_matrix*/
-    //        {
-    //            sci_strcat_rhs_one_is_a_matrix(fname);
-    //        }
-    //    }
-    //    return 0;
-    //}
-    ///*-------------------------------------------------------------------------------------*/
-    //static int sci_strcat_rhs_one_is_a_matrix(char *fname)
-    //{
-    //    /* strcat([],'A') returns a empty string matrix */
-    //    double *Input_String_One = NULL;
-    //    int Row_One = 0,Col_One = 0;
-    //
-    //    GetRhsVar(1,MATRIX_OF_DOUBLE_DATATYPE,&Row_One,&Col_One,&Input_String_One);
-    //
-    //    /* check that we have [] */
-    //    if ((Row_One == 0) && (Col_One == 0))
-    //    {
-    //        int one    = 1 ;
-    //        int len   = (int)strlen(EMPTY_CHAR);
-    //        int outIndex = 0 ;
-    //
-    //        CreateVar(Rhs+1,STRING_DATATYPE,&len,&one,&outIndex);
-    //        strcpy(cstk(outIndex),EMPTY_CHAR);
-    //        LhsVar(1) = Rhs+1 ;
-    //        C2F(putlhsvar)();
-    //    }
-    //    else
-    //    {
-    //        Scierror(999,_("%s: Wrong type for input argument #%d: Matrix of strings or empty real matrix expected.\n"),fname,1);
-    //    }
-    //    return 0;
-    //}
-    ///*-------------------------------------------------------------------------------------*/
-    //static int sumlengthstring(int rhspos)
-    //{
-    //    int sizelengths = 0;
-    //    int sumlength = -1; /* error */
-    //    int *lengths = lengthEachString(rhspos, &sizelengths);
-    //    int i = 0;
-    //    if (lengths)
-    //    {
-    //        sumlength = 0;
-    //        for(i = 0;i < sizelengths; i++)
-    //        {
-    //            sumlength = sumlength + lengths[i];
-    //        }
-    //        FREE(lengths); lengths = NULL;
-    //    }
-    //
-    //    return sumlength;
-    //}
-    ///*-------------------------------------------------------------------------------------*/
-    //static int *lengthEachString(int rhspos, int *sizeArrayReturned)
-    //{
-    //    int *StringsLength = NULL;
-    //
-    //    if (VarType(rhspos) == sci_strings)
-    //    {
-    //        int m = 0, n = 0; /* matrix size */
-    //        int mn = 0; /* m*n */
-    //
-    //        int il = 0; int ilrd = 0;
-    //        int l1 = 0;
-    //
-    //        int x = 0;
-    //
-    //        int lw = rhspos + Top - Rhs;
-    //        int lenstrcat = 0;
-    //
-    //        l1 = *Lstk(lw);
-    //        il = iadr(l1);
-    //
-    //        if (*istk(il ) < 0) il = iadr(*istk(il + 1));
-    //
-    //        /* get dimensions */
-    //        m = getNumberOfLines(il); /* row */
-    //        n = getNumberOfColumns(il); /* col */
-    //        mn = m * n ;
-    //        ilrd = il + 4;
-    //
-    //        StringsLength = (int*)MALLOC(sizeof(int) * mn);
-    //        if (StringsLength == NULL) return NULL;
-    //
-    //        *sizeArrayReturned = mn;
-    //
-    //        for  ( x = 0; x < mn; x++ )
-    //        {
-    //            StringsLength[x]=  (int) (*istk(ilrd + x + 1) - *istk(ilrd + x));
-    //        }
-    //    }
-    //    return StringsLength;
 }
 /*-------------------------------------------------------------------------------------*/
index 7e6ac8c..35866a8 100644 (file)
@@ -97,6 +97,7 @@ types::Function::ReturnValue sci_strcmp(types::typed_list &in, int _iRetCount, t
     {
         pOutDouble  = new types::Double(pString1->getDims(), pString1->getDimsArray());
         pOutDouble->setInt(values);
+        FREE(values);
     }
     else
     {
index 10b16aa..138eace 100644 (file)
@@ -24,6 +24,7 @@ extern "C"
 #include "Scierror.h"
 #include "localization.h"
 #include "strsplit.h"
+#include "freeArrayOfString.h"
 }
 
 types::Function::ReturnValue sci_strsplit(types::typed_list &in, int _iRetCount, types::typed_list &out)
@@ -129,38 +130,35 @@ types::Function::ReturnValue sci_strsplit(types::typed_list &in, int _iRetCount,
                     types::String* pStrOut = new types::String(pDbl->getSize() + 1, 1);
                     pStrOut->set(results);
 
-                    for (int i = 0; i < pStrIn->getSize(); i++)
-                    {
-                        FREE(results[i]);
-                        results[i] = NULL;
-                    }
-                    FREE(results);
-                    results = NULL;
-
+                    freeArrayOfWideString(results, pDbl->getSize() + 1);
                     out.push_back(pStrOut);
                     return types::Function::OK;
                 }
                 break;
                 case STRSPLIT_INCORRECT_VALUE_ERROR:
                 {
+                    freeArrayOfWideString(results, pDbl->getSize() + 1);
                     Scierror(999, _("%s: Wrong value for input argument #%d.\n"), "strsplit", 2);
                     return types::Function::Error;
                 }
                 break;
                 case STRSPLIT_INCORRECT_ORDER_ERROR:
                 {
+                    freeArrayOfWideString(results, pDbl->getSize() + 1);
                     Scierror(999, _("%s: Elements of %dth argument must be in increasing order.\n"), "strsplit", 2);
                     return types::Function::Error;
                 }
                 break;
                 case STRSPLIT_MEMORY_ALLOCATION_ERROR:
                 {
+                    freeArrayOfWideString(results, pDbl->getSize() + 1);
                     Scierror(999, _("%s: Memory allocation error.\n"), "strsplit");
                     return types::Function::Error;
                 }
                 break;
                 default:
                 {
+                    freeArrayOfWideString(results, pDbl->getSize() + 1);
                     Scierror(999, _("%s: error.\n"), "strsplit");
                     return types::Function::Error;
                 }
index 79004ab..406b55e 100644 (file)
@@ -10,8 +10,8 @@
  *
  */
 
-//for Visual Leak Detector
-#ifdef DEBUG_VLD
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
 #include <vld.h>
 #endif
 
index 7f6ed83..bb61909 100644 (file)
  *
  */
 
-//for Visual Leak Detector
-#ifdef DEBUG_VLD
-#include <vld.h>
-#endif
-
-
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/pcre.lib")
 #pragma comment(lib,"../../../../bin/pcreposix.lib")
 #pragma comment(lib,"../../../../bin/libintl.lib")
index f160dd2..08ba827 100644 (file)
@@ -1205,6 +1205,9 @@ pcre_error_code wide_pcre_private(wchar_t* _pwstInput, wchar_t* _pwstPattern, in
             freeArrayOfString(pstCaptured, *_piCapturedStringCount);
         }
     }
+
+    FREE(pstInput);
+    FREE(pstPattern);
     return iPcreStatus;
 }
 /*-------------------------------------------------------------------------------*/
index 0d4d3b4..adec142 100644 (file)
  */
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 4a3bf40..71280bc 100644 (file)
 #include <windows.h>
 #include "tcl.h"
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 #if defined(TCL_MAJOR_VERSION) && defined(TCL_MAJOR_VERSION)
index 4ace23a..648da2a 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 271042a..0fd1a9e 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 9977a31..773a046 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libumfpack.lib")
 #pragma comment(lib,"../../../../bin/blasplus.lib")
 #pragma comment(lib,"../../../../bin/lapack.lib")
index 53ca65b..9a86187 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 4225240..7a164a3 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index 8996783..d16421c 100644 (file)
 
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
index ddbb058..ad5f033 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
+//for Visual Leak Detector in debug compilation mode
+#if defined(DEBUG_VLD) && defined(_DEBUG)
+#include <vld.h>
+#endif
+/*--------------------------------------------------------------------------*/
 #pragma comment(lib,"../../bin/libxml2.lib")
 #pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/