fix api_scilab memleaks 45/17145/3
Antoine ELIAS [Tue, 1 Sep 2015 14:09:07 +0000 (16:09 +0200)]
Change-Id: I989c2d3ecfab0264c63e5919a9239a9e7448374f

32 files changed:
scilab/modules/api_scilab/src/cpp/api_boolean_sparse.cpp
scilab/modules/api_scilab/src/cpp/api_common.cpp
scilab/modules/api_scilab/src/cpp/api_error.cpp
scilab/modules/api_scilab/src/cpp/api_internal_common.h
scilab/modules/api_scilab/src/cpp/api_sparse.cpp
scilab/modules/api_scilab/tests/nonreg_tests/bug_11538.c
scilab/modules/api_scilab/tests/nonreg_tests/bug_8587.c
scilab/modules/api_scilab/tests/unit_tests/common_read_api.c
scilab/modules/api_scilab/tests/unit_tests/common_read_api.tst
scilab/modules/api_scilab/tests/unit_tests/deleteNamedVariable.c
scilab/modules/api_scilab/tests/unit_tests/list_createlist_api.c
scilab/modules/api_scilab/tests/unit_tests/list_createlist_api.dia.ref
scilab/modules/api_scilab/tests/unit_tests/list_createlist_api.tst
scilab/modules/api_scilab/tests/unit_tests/pointer_reading_api.c
scilab/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.c
scilab/modules/api_scilab/tests/unit_tests/sparse_reading_api.c
scilab/modules/fileio/src/c/fullpath.c
scilab/modules/graphic_export/Makefile.am
scilab/modules/graphic_export/Makefile.in
scilab/modules/graphic_export/graphic_export.vcxproj
scilab/modules/graphic_export/graphic_export.vcxproj.filters
scilab/modules/graphic_export/src/cpp/xs2file.cpp [moved from scilab/modules/graphic_export/sci_gateway/c/xs2file.c with 98% similarity]
scilab/modules/graphic_export/src/cpp/xs2file.h [moved from scilab/modules/graphic_export/sci_gateway/c/xs2file.h with 100% similarity]
scilab/modules/graphic_objects/includes/Plot3DDecomposer.hxx
scilab/modules/graphic_objects/src/cpp/DllmainGraphic_objects.cpp
scilab/modules/graphics/src/c/GetProperty.c
scilab/modules/graphics/src/c/getHandleProperty/get_children_property.c
scilab/modules/graphics/src/c/getHandleProperty/get_position_property.c
scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v3.cpp
scilab/modules/hdf5/src/cpp/handle_properties.cpp
scilab/modules/io/tests/nonreg_tests/bug_14058.dia.ref [moved from scilab/modules/io/tests/unit_tests/bug_14058.dia.ref with 100% similarity]
scilab/modules/io/tests/nonreg_tests/bug_14058.tst [moved from scilab/modules/io/tests/unit_tests/bug_14058.tst with 100% similarity]

index 5e6c1b2..2440703 100644 (file)
@@ -267,6 +267,8 @@ int getAllocatedBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows,
     *_piColPos                 = (int*)MALLOC(sizeof(int) **_piNbItem);
     memcpy(*_piColPos, piColPos, sizeof(int) **_piNbItem);
 
+    FREE(piNbItemRow);
+    FREE(piColPos);
     return 0;
 }
 /*--------------------------------------------------------------------------*/
index 824576f..adb02ac 100644 (file)
@@ -1495,6 +1495,7 @@ int isNamedVarExist(void *_pvCtx, const char *_pstName)
     sciErr = getVarAddressFromName(_pvCtx, _pstName, &piAddr);
     if (sciErr.iErr || piAddr == NULL)
     {
+        sciErrClean(&sciErr);
         return 0;
     }
 
@@ -1611,3 +1612,14 @@ SciErr sciErrInit()
     return sciErr;
 }
 
+void sciErrClean(SciErr* _psciErr)
+{
+    //reset error
+    for (int i = _psciErr->iMsgCount - 1; i >= 0; i--)
+    {
+        FREE(_psciErr->pstMsg[i]);
+    }
+
+    _psciErr->iMsgCount = 0;
+    _psciErr->iErr = 0;
+}
\ No newline at end of file
index 7ee6aab..cf51172 100644 (file)
@@ -23,6 +23,7 @@ extern "C"
 #include "os_string.h"
 #include "localization.h"
 #include "configvariable_interface.h"
+#include "api_internal_common.h"
 }
 
 int addErrorMessage(SciErr* _psciErr, int _iErr, const char* _pstMsg, ...)
@@ -67,25 +68,25 @@ int printError(SciErr* _psciErr, int _iLastMsg)
 
     SciStoreError(_psciErr->iErr);
 
-    if (getPromptMode() == PROMPTMODE_SILENT || getSilentError() != VERBOSE_ERROR)
+    if (getPromptMode() != PROMPTMODE_SILENT && getSilentError() == VERBOSE_ERROR)
     {
-        return 0;
-    }
-
-    if (_iLastMsg)
-    {
-        sciprint(_("API Error:\n"));
-        sciprint(_("\tin %s\n"), _psciErr->pstMsg[0]);
-    }
-    else
-    {
-        sciprint(_("API Error:\n"));
-
-        for (int i = _psciErr->iMsgCount - 1 ;  i >= 0 ; i--)
+        if (_iLastMsg)
+        {
+            sciprint(_("API Error:\n"));
+            sciprint(_("\tin %s\n"), _psciErr->pstMsg[0]);
+        }
+        else
         {
-            sciprint(_("\tin %s\n"), _psciErr->pstMsg[i]);
+            sciprint(_("API Error:\n"));
+
+            for (int i = _psciErr->iMsgCount - 1; i >= 0; i--)
+            {
+                sciprint(_("\tin %s\n"), _psciErr->pstMsg[i]);
+            }
         }
     }
+
+    sciErrClean(_psciErr);
     return 0;
 }
 
index 4e7eb1f..1090748 100644 (file)
@@ -57,6 +57,7 @@ int checkNamedVarFormat(void* _pvCtx, const char *_pstName);
 
 
 SciErr sciErrInit();
+void sciErrClean(SciErr* _psciErr);
 
 #endif /* __INTERNAL_COMMON_API__ */
 
index 418ee0a..d847239 100644 (file)
@@ -441,12 +441,18 @@ static int getCommonAllocatedSparseMatrix(void* _pvCtx, int* _piAddress, int _iC
     *_pdblReal = (double*)MALLOC(sizeof(double) **_piNbItem);
     C2F(dcopy)(_piNbItem, pdblReal, &iOne, *_pdblReal, &iOne);
 
+    FREE(piNbItemRow);
+    FREE(piColPos);
+    FREE(pdblReal);
+
     if (_iComplex)
     {
         *_pdblImg = (double*)MALLOC(sizeof(double) **_piNbItem);
         C2F(dcopy)(_piNbItem, pdblImg, &iOne, *_pdblImg, &iOne);
+        FREE(pdblImg);
     }
 
+
     return 0;
 }
 /*--------------------------------------------------------------------------*/
index 961b53f..191e52f 100644 (file)
@@ -38,11 +38,14 @@ int sci_bug_11538(char* fname, void* pvApiCtx)
         return 1;
     }
 
+    FREE(pstData);
+
     if (getAllocatedSingleWideString(pvApiCtx, piAddr, &pwstData))
     {
         Scierror(999, "Failed to get data as wide string");
         return 1;
     }
 
+    FREE(pwstData);
     return 0;
 }
index aed6ff3..a23d37b 100644 (file)
@@ -43,6 +43,7 @@ int sci_readDoubles(char *fname, void* pvApiCtx)
         printError(&sciErr, 0);
     }
 
+    FREE(matrixOfDouble);
     LhsVar(1) = Rhs + 1;
     return 0;
 }
index ba27354..d1f9872 100644 (file)
@@ -372,6 +372,11 @@ int get_sparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _
         }
     }
 
+    FREE(piNbRow);
+    FREE(piColPos);
+    FREE(pdblReal);
+    FREE(pdblImg);
+
     insert_indent();
     sciprint("Sparse (%d x %d), Item(s) : %d \n", iRows, iCols, iItem);
     return 0;;
@@ -402,6 +407,9 @@ int get_bsparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int
         return 0;
     }
 
+    FREE(piNbRow);
+    FREE(piColPos);
+
     insert_indent();
     sciprint("Boolean Sparse (%d x %d), Item(s) : %d \n", iRows, iCols, iItem);
     return 0;;
@@ -582,6 +590,14 @@ int get_string_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _
         return 0;
     }
 
+    for (i = 0 ; i < iRows * iCols ; i++)
+    {
+        FREE(pstData[i]);
+    }
+
+    FREE(pstData);
+    FREE(piLen);
+
     insert_indent();
     sciprint("Strings (%d x %d)\n", iRows, iCols);
     return 0;;
index bd8c3f0..8ff45ab 100644 (file)
@@ -25,12 +25,7 @@ bsp=sparse([1,2;4,5;3,10],[%t,%t,%t]);common_read(bsp);
 i8 = int8([1,2,3]);common_read(i8);
 ui32 = uint32([3;2;1]);common_read(ui32);
 str = ["may", "the", "puffin"; "be", "with","you"];common_read(str);
-if with_module('umfpack') then
-    Cp = taucs_chfact(sp);
-    l = list(list(d, p, list(b, sp)), list(i8, bsp), list(ui32, str), Cp);
-else
-    l = list(list(d, p, list(b, sp)), list(i8, bsp), list(ui32, str));
-end
+l = list(list(d, p, list(b, sp)), list(i8, bsp), list(ui32, str));
 common_read(l)
 endfunction
 read_all;
index 86f28de..499adc2 100644 (file)
@@ -40,6 +40,7 @@ int sci_deleteNamedVariable(char *fname, void* pvApiCtx)
         iRet = deleteNamedVariable(pvApiCtx, pstVarName);
     }
 
+    freeAllocatedSingleString(pstVarName);
     createScalarBoolean(pvApiCtx, Rhs + 1, iRet);
     AssignOutputVariable(pvApiCtx, 1) = Rhs + 1;
     return 0;
index ccebf96..9b4338a 100644 (file)
@@ -38,7 +38,6 @@ int list_createlist(char *fname, void* pvApiCtx)
     double pdblSReal[]      = {1, 2, 3, 4};
     double pdblSImg[]       = {4, 3, 2, 1};
     int piBool[]            = {1, 0, 1, 0, 1, 0, 1, 0, 1};
-    double* pdblDataPtr     = NULL;
 
     sciErr = createList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 8, &piAddr);
     if (sciErr.iErr)
@@ -95,7 +94,7 @@ int list_createlist(char *fname, void* pvApiCtx)
     }
 
     //add list in list
-    sciErr = createListInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 8, 3, &piChild);
+    sciErr = createListInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 8, 2, &piChild);
     if (sciErr.iErr)
     {
         printError(&sciErr, 0);
@@ -116,19 +115,6 @@ int list_createlist(char *fname, void* pvApiCtx)
         return 0;
     }
 
-    pdblDataPtr     = (double*)MALLOC(sizeof(double) * 4);
-    pdblDataPtr[0]  = 1;
-    pdblDataPtr[1]  = 2;
-    pdblDataPtr[2]  = 3;
-    pdblDataPtr[3]  = 4;
-
-    sciErr = createPointerInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piChild, 3, pdblDataPtr);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        return 0;
-    }
-
     AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
     return 0;
 }
index 2476f5f..0384bf9 100644 (file)
@@ -14,7 +14,7 @@ ilib_build("gw_list_createlist",["list_createlist","list_createlist"],"list_crea
 exec("loader.sce");
 size_ref    = 8;
 type_ref    = ["constant","string","int16","polynomial", "sparse", "boolean", "boolean sparse", "list"];
-dim_ref     = list([3,2],[2,3],[2,3],[3,2],[3,10],[3,3],[3,10],3);
+dim_ref     = list([3,2],[2,3],[2,3],[3,2],[3,10],[3,3],[3,10],2);
 l = list_createlist();
 if size(l) <> size_ref then bugmes();quit;end
 for i = 1 : size_ref
index 4bb5a3a..baa5983 100644 (file)
@@ -16,7 +16,7 @@ exec("loader.sce");
 
 size_ref    = 8;
 type_ref    = ["constant","string","int16","polynomial", "sparse", "boolean", "boolean sparse", "list"];
-dim_ref     = list([3,2],[2,3],[2,3],[3,2],[3,10],[3,3],[3,10],3);
+dim_ref     = list([3,2],[2,3],[2,3],[3,2],[3,10],[3,3],[3,10],2);
 l = list_createlist();
 if size(l) <> size_ref then pause;end
 for i = 1 : size_ref
index 41c11e0..cfb6a8c 100644 (file)
@@ -54,6 +54,7 @@ int read_pointer(char *fname, void* pvApiCtx)
         }
         pdblData = (double*)pvPtr;
         sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 2, 2, pdblData);
+        FREE(pvPtr);
     }
     else
     {
index 135272f..d285368 100644 (file)
@@ -85,6 +85,9 @@ int read_write_bsparse(char *fname, void* pvApiCtx)
         iCol += piNbItemRow[i];
     }
 
+    FREE(piNbItemRow);
+    FREE(piColPos);
+
     sciErr = createBooleanSparseMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, iNewItem, piNewRow, piNewCol);
     if (sciErr.iErr)
     {
@@ -92,6 +95,9 @@ int read_write_bsparse(char *fname, void* pvApiCtx)
         return 0;
     }
 
+    FREE(piNewRow);
+    FREE(piNewCol);
+
     AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
     return 0;
 }
index 95e54d2..d17b043 100644 (file)
@@ -70,6 +70,11 @@ int read_sparse(char *fname, void* pvApiCtx)
         }
     }
 
+    FREE(piNbItemRow);
+    FREE(piColPos);
+    FREE(pdblReal);
+    FREE(pdblImg);
+
     //assign allocated variables to Lhs position
     AssignOutputVariable(pvApiCtx, 1) = 0;
     return 0;
index 157c1c7..9719c36 100644 (file)
@@ -84,9 +84,10 @@ char *get_full_path(char *_FullPath, const char *_Path, size_t _SizeInBytes)
             int ierr = 0;
             char* pstCurrentPath = scigetcwd(&ierr);
             //alloc buffer + 2, 1 for '/' and 1 for null termination
-            pstWorkingPath = (char*)MALLOC(sizeof(char) * (lenPath + strlen(pstCurrentPath) + 2));
+            pstWorkingPath = (char*)CALLOC(sizeof(char), (lenPath + strlen(pstCurrentPath) + 2));
             sprintf(pstWorkingPath, "%s/%s", pstCurrentPath, _Path);
             lenPath = strlen(pstWorkingPath);
+            FREE(pstCurrentPath);
         }
         else
         {
index e7f92c5..8a8bd07 100644 (file)
@@ -28,12 +28,12 @@ libscigraphic_export_la_etc_DATA = \
 # List of the c files
 GRAPHIC_EXPORT_CXX_SOURCES = \
     src/cpp/exportToFile.cpp \
+    src/cpp/xs2file.cpp \
     src/jni/FileExporter.cpp \
     src/jni/Driver.cpp
-
+    
 # List of the gateway c files
 GATEWAY_C_SOURCES = \
-    sci_gateway/c/xs2file.c \
     sci_gateway/c/sci_xs2bmp.c \
     sci_gateway/c/sci_xs2gif.c \
     sci_gateway/c/sci_xs2ppm.c \
index 035e489..5928bb9 100644 (file)
@@ -182,6 +182,7 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES)
 libscigraphic_export_algo_la_LIBADD =
 am__dirstamp = $(am__leading_dot)dirstamp
 am__objects_1 = src/cpp/libscigraphic_export_algo_la-exportToFile.lo \
+       src/cpp/libscigraphic_export_algo_la-xs2file.lo \
        src/jni/libscigraphic_export_algo_la-FileExporter.lo \
        src/jni/libscigraphic_export_algo_la-Driver.lo
 am_libscigraphic_export_algo_la_OBJECTS = $(am__objects_1)
@@ -197,8 +198,7 @@ am_libscigraphic_export_disable_la_OBJECTS = src/nographic_export/libscigraphic_
 libscigraphic_export_disable_la_OBJECTS =  \
        $(am_libscigraphic_export_disable_la_OBJECTS)
 libscigraphic_export_la_DEPENDENCIES = libscigraphic_export-algo.la
-am__objects_2 = sci_gateway/c/libscigraphic_export_la-xs2file.lo \
-       sci_gateway/c/libscigraphic_export_la-sci_xs2bmp.lo \
+am__objects_2 = sci_gateway/c/libscigraphic_export_la-sci_xs2bmp.lo \
        sci_gateway/c/libscigraphic_export_la-sci_xs2gif.lo \
        sci_gateway/c/libscigraphic_export_la-sci_xs2ppm.lo \
        sci_gateway/c/libscigraphic_export_la-sci_xs2ps.lo \
@@ -606,13 +606,13 @@ libscigraphic_export_la_etc_DATA = \
 # List of the c files
 GRAPHIC_EXPORT_CXX_SOURCES = \
     src/cpp/exportToFile.cpp \
+    src/cpp/xs2file.cpp \
     src/jni/FileExporter.cpp \
     src/jni/Driver.cpp
 
 
 # List of the gateway c files
 GATEWAY_C_SOURCES = \
-    sci_gateway/c/xs2file.c \
     sci_gateway/c/sci_xs2bmp.c \
     sci_gateway/c/sci_xs2gif.c \
     sci_gateway/c/sci_xs2ppm.c \
@@ -861,6 +861,8 @@ src/cpp/$(DEPDIR)/$(am__dirstamp):
        @: > src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libscigraphic_export_algo_la-exportToFile.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscigraphic_export_algo_la-xs2file.lo:  \
+       src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/jni/$(am__dirstamp):
        @$(MKDIR_P) src/jni
        @: > src/jni/$(am__dirstamp)
@@ -892,9 +894,6 @@ sci_gateway/c/$(am__dirstamp):
 sci_gateway/c/$(DEPDIR)/$(am__dirstamp):
        @$(MKDIR_P) sci_gateway/c/$(DEPDIR)
        @: > sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
-sci_gateway/c/libscigraphic_export_la-xs2file.lo:  \
-       sci_gateway/c/$(am__dirstamp) \
-       sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/c/libscigraphic_export_la-sci_xs2bmp.lo:  \
        sci_gateway/c/$(am__dirstamp) \
        sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
@@ -970,11 +969,11 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-sci_xs2ppm.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-sci_xs2ps.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-sci_xs2svg.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-xs2file.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigraphic_export_la-sci_driver.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigraphic_export_la-sci_xend.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscigraphic_export_la-sci_xinit.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_export_algo_la-exportToFile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscigraphic_export_algo_la-xs2file.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscigraphic_export_algo_la-Driver.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/jni/$(DEPDIR)/libscigraphic_export_algo_la-FileExporter.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/nographic_export/$(DEPDIR)/libscigraphic_export_disable_la-nographic_export.Plo@am__quote@
@@ -1010,13 +1009,6 @@ src/nographic_export/libscigraphic_export_disable_la-nographic_export.lo: src/no
 @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) $(libscigraphic_export_disable_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/nographic_export/libscigraphic_export_disable_la-nographic_export.lo `test -f 'src/nographic_export/nographic_export.c' || echo '$(srcdir)/'`src/nographic_export/nographic_export.c
 
-sci_gateway/c/libscigraphic_export_la-xs2file.lo: sci_gateway/c/xs2file.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_export_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscigraphic_export_la-xs2file.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-xs2file.Tpo -c -o sci_gateway/c/libscigraphic_export_la-xs2file.lo `test -f 'sci_gateway/c/xs2file.c' || echo '$(srcdir)/'`sci_gateway/c/xs2file.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-xs2file.Tpo sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-xs2file.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/xs2file.c' object='sci_gateway/c/libscigraphic_export_la-xs2file.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) $(libscigraphic_export_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscigraphic_export_la-xs2file.lo `test -f 'sci_gateway/c/xs2file.c' || echo '$(srcdir)/'`sci_gateway/c/xs2file.c
-
 sci_gateway/c/libscigraphic_export_la-sci_xs2bmp.lo: sci_gateway/c/sci_xs2bmp.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_export_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscigraphic_export_la-sci_xs2bmp.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-sci_xs2bmp.Tpo -c -o sci_gateway/c/libscigraphic_export_la-sci_xs2bmp.lo `test -f 'sci_gateway/c/sci_xs2bmp.c' || echo '$(srcdir)/'`sci_gateway/c/sci_xs2bmp.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-sci_xs2bmp.Tpo sci_gateway/c/$(DEPDIR)/libscigraphic_export_la-sci_xs2bmp.Plo
@@ -1118,6 +1110,13 @@ src/cpp/libscigraphic_export_algo_la-exportToFile.lo: src/cpp/exportToFile.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_export_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscigraphic_export_algo_la-exportToFile.lo `test -f 'src/cpp/exportToFile.cpp' || echo '$(srcdir)/'`src/cpp/exportToFile.cpp
 
+src/cpp/libscigraphic_export_algo_la-xs2file.lo: src/cpp/xs2file.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_export_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscigraphic_export_algo_la-xs2file.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscigraphic_export_algo_la-xs2file.Tpo -c -o src/cpp/libscigraphic_export_algo_la-xs2file.lo `test -f 'src/cpp/xs2file.cpp' || echo '$(srcdir)/'`src/cpp/xs2file.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscigraphic_export_algo_la-xs2file.Tpo src/cpp/$(DEPDIR)/libscigraphic_export_algo_la-xs2file.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/xs2file.cpp' object='src/cpp/libscigraphic_export_algo_la-xs2file.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_export_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscigraphic_export_algo_la-xs2file.lo `test -f 'src/cpp/xs2file.cpp' || echo '$(srcdir)/'`src/cpp/xs2file.cpp
+
 src/jni/libscigraphic_export_algo_la-FileExporter.lo: src/jni/FileExporter.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_export_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/jni/libscigraphic_export_algo_la-FileExporter.lo -MD -MP -MF src/jni/$(DEPDIR)/libscigraphic_export_algo_la-FileExporter.Tpo -c -o src/jni/libscigraphic_export_algo_la-FileExporter.lo `test -f 'src/jni/FileExporter.cpp' || echo '$(srcdir)/'`src/jni/FileExporter.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/jni/$(DEPDIR)/libscigraphic_export_algo_la-FileExporter.Tpo src/jni/$(DEPDIR)/libscigraphic_export_algo_la-FileExporter.Plo
index 7e3a9a6..6625127 100644 (file)
@@ -252,8 +252,8 @@ lib /DEF:"$(ProjectDir)graphics_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfo
     <ClCompile Include="sci_gateway\cpp\sci_xend.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_xinit.cpp" />
     <ClCompile Include="sci_gateway\c\sci_xs2emf.c" />
-    <ClCompile Include="sci_gateway\c\xs2file.c" />
     <ClCompile Include="src\cpp\exportToFile.cpp" />
+    <ClCompile Include="src\cpp\xs2file.cpp" />
     <ClCompile Include="src\jni\Driver.cpp" />
     <ClCompile Include="src\jni\FileExporter.cpp" />
     <ClCompile Include="src\c\DllmainGraphics_export.c" />
@@ -270,8 +270,8 @@ lib /DEF:"$(ProjectDir)graphics_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platfo
   <ItemGroup>
     <ClInclude Include="includes\dynlib_graphic_export.h" />
     <ClInclude Include="includes\gw_graphic_export.h" />
-    <ClInclude Include="includes\xs2file.h" />
     <ClInclude Include="src\cpp\exportToFile.hxx" />
+    <ClInclude Include="src\cpp\xs2file.h" />
     <ClInclude Include="src\jni\Driver.hxx" />
     <ClInclude Include="src\jni\FileExporter.hxx" />
   </ItemGroup>
index 67f801b..f3ec216 100644 (file)
     <ClCompile Include="sci_gateway\cpp\sci_xinit.cpp">
       <Filter>Source Files\cpp</Filter>
     </ClCompile>
-    <ClCompile Include="sci_gateway\c\xs2file.c">
-      <Filter>Source Files\c</Filter>
-    </ClCompile>
     <ClCompile Include="sci_gateway\c\sci_xs2emf.c">
       <Filter>Source Files\c</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\xs2file.cpp">
+      <Filter>Source Files\cpp</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\dynlib_graphic_export.h">
     <ClInclude Include="src\jni\Driver.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="includes\xs2file.h">
+    <ClInclude Include="src\cpp\xs2file.h">
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>
@@ -17,6 +17,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+extern "C"
+{
 #include "xs2file.h"
 #include "api_scilab.h"
 #include "GetProperty.h"
 #include "HandleManagement.h"
 #include "getGraphicObjectProperty.h"
 #include "graphicObjectProperties.h"
+}
 
 /*--------------------------------------------------------------------------*/
-static BOOL isVectorialExport(ExportFileType fileType);
+static bool isVectorialExport(ExportFileType fileType);
 /*--------------------------------------------------------------------------*/
 int xs2file(char * fname, ExportFileType fileType, void* pvApiCtx)
 {
@@ -279,8 +282,11 @@ int xs2file(char * fname, ExportFileType fileType, void* pvApiCtx)
             if (strlen(status) != 0)
             {
                 Scierror(999, _("%s: %s\n"), fname, status);
+                delete[] status;
                 return 1;
             }
+
+            delete[] status;
         }
         else
         {
@@ -301,7 +307,7 @@ int xs2file(char * fname, ExportFileType fileType, void* pvApiCtx)
     return 0;
 }
 /*--------------------------------------------------------------------------*/
-static BOOL isVectorialExport(ExportFileType fileType)
+static bool isVectorialExport(ExportFileType fileType)
 {
     return fileType == EPS_EXPORT
            || fileType == PS_EXPORT
index 99383f0..29cca17 100644 (file)
@@ -88,6 +88,14 @@ public :
         return decomposer;
     }
 
+    static void destroy()
+    {
+        if (decomposer)
+        {
+            delete decomposer;
+            decomposer = NULL;
+        }
+    }
     /**
      * Fills the given buffer with vertex data from the given object.
      * @param[in] the id of the given object.
index c4c3610..b7eb028 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include "DataModel.hxx"
+#include "Plot3DDecomposer.hxx"
 #ifdef _MSC_VER
 #include <windows.h>
 /*--------------------------------------------------------------------------*/
@@ -35,6 +36,7 @@ int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
             break;
         case DLL_PROCESS_DETACH:
             DataModel::destroy();
+            Plot3DDecomposer::destroy();
             break;
         case DLL_THREAD_ATTACH:
             break;
@@ -54,6 +56,7 @@ void load(void)
 void unload(void)
 {
     DataModel::destroy();
+    Plot3DDecomposer::destroy();
 }
 #endif
 /*--------------------------------------------------------------------------*/
index cae7272..3c43325 100644 (file)
@@ -88,6 +88,8 @@ BOOL sciisTextEmpty(int iObjUID)
 
     nbElements = dimensions[0] * dimensions[1];
 
+    releaseGraphicObjectProperty(__GO_TEXT_ARRAY_DIMENSIONS__, dimensions, jni_int_vector, 2);
+
     if (nbElements == 0)
     {
         return TRUE;
@@ -96,18 +98,21 @@ BOOL sciisTextEmpty(int iObjUID)
     if (nbElements == 1)
     {
         char** textMatrix = NULL;
+        BOOL ret = FALSE;
         getGraphicObjectProperty(iObjUID, __GO_TEXT_STRINGS__, jni_string_vector, (void **) &textMatrix);
 
         if (textMatrix[0] == NULL)
         {
-            return TRUE;
+            ret = TRUE;
         }
         else if (strcmp(textMatrix[0], "") == 0)
         {
             /* empty string */
-            return TRUE;
+            ret = TRUE;
         }
 
+        releaseGraphicObjectProperty(__GO_TEXT_STRINGS__, textMatrix, jni_string_vector, nbElements);
+        return ret;
     }
 
     return FALSE;
index 8e78805..00748fe 100644 (file)
@@ -82,6 +82,7 @@ void* get_children_property(void* _pvCtx, int iObjUID)
         if (childrenNumber == 0)
         {
             // No Child
+            releaseGraphicObjectProperty(__GO_CHILDREN__, piChildrenUID, jni_int_vector, iChildrenCount);
             return sciReturnEmptyMatrix();
         }
     }
@@ -100,6 +101,7 @@ void* get_children_property(void* _pvCtx, int iObjUID)
         if (childrenNumber == 0)
         {
             // No Child
+            releaseGraphicObjectProperty(__GO_CHILDREN__, piChildrenUID, jni_int_vector, iChildrenCount);
             return sciReturnEmptyMatrix();
         }
 
@@ -112,17 +114,17 @@ void* get_children_property(void* _pvCtx, int iObjUID)
         getGraphicObjectProperty(piChildrenUID[i], __GO_HIDDEN__, jni_bool, (void **)&piHidden);
         if (iHidden == 0 || iShowHiddenHandles == 1)
         {
-           getGraphicObjectProperty(piChildrenUID[i], __GO_TYPE__, jni_int, (void**) &piType);
-           if (type != __GO_DATATIP__)
-           {
+            getGraphicObjectProperty(piChildrenUID[i], __GO_TYPE__, jni_int, (void**)&piType);
+            if (type != __GO_DATATIP__)
+            {
                 plChildren[iChildIndex++] = getHandle(piChildrenUID[i]);
-           }
+            }
         }
     }
 
     status = sciReturnColHandleVector(plChildren, childrenNumber);
     FREE(plChildren);
-
+    releaseGraphicObjectProperty(__GO_CHILDREN__, piChildrenUID, jni_int_vector, iChildrenCount);
     return status;
 }
 
index 2c745aa..9a56a60 100644 (file)
@@ -69,7 +69,10 @@ void* get_position_property(void* _pvCtx, int iObjUID)
         position[2] = (double) figureSize[0];
         position[3] = (double) figureSize[1];
 
-        return sciReturnRowVector(position, 4);
+        ret = sciReturnRowVector(position, 4);
+        releaseGraphicObjectProperty(__GO_POSITION__, figurePosition, jni_int_vector, 2);
+        releaseGraphicObjectProperty(__GO_AXES_SIZE__, figureSize, jni_int_vector, 2);
+        return ret;
     }
 
     /* Special label and legend case : only 2 values for position */
@@ -85,7 +88,9 @@ void* get_position_property(void* _pvCtx, int iObjUID)
             return NULL;
         }
 
-        return sciReturnRowVector(position, 2);
+        ret = sciReturnRowVector(position, 2);
+        releaseGraphicObjectProperty(__GO_POSITION__, position, jni_double_vector, 2);
+        return ret;
     }
 
     if (iType == __GO_LIGHT__)
@@ -100,7 +105,9 @@ void* get_position_property(void* _pvCtx, int iObjUID)
             return NULL;
         }
 
-        return sciReturnRowVector(position, 3);
+        ret = sciReturnRowVector(position, 3);
+        releaseGraphicObjectProperty(__GO_POSITION__, position, jni_double_vector, 3);
+        return ret;
     }
 
     /* Generic case : position is a 4 row vector */
index 6d8a932..d45394c 100644 (file)
@@ -1027,7 +1027,7 @@ static types::InternalType* import_macro(int dataset)
 
     //wname+1 is to remove "/" at the start of the var name from HDF5
     types::Macro* macro = new types::Macro(L"", *inputList, *outputList, *body->getAs<ast::SeqExp>(), L"script");
-
+    delete body;
     closeList6(dataset);
     return macro;
 }
index 0e5f7c7..638e23a 100644 (file)
@@ -859,6 +859,7 @@ static int import_handle_uicontrol(int dataset, int parent)
     setGraphicObjectProperty(uic, __GO_UI_STRING_COLNB__, &col, jni_int, 1);
     setGraphicObjectProperty(uic, __GO_UI_STRING__, string, jni_string_vector, row * col);
     freeStringMatrix(node, string);
+    delete[] string;
 
     //border
     int dborder = getDataSetIdFromName(dataset, "border");
@@ -938,7 +939,7 @@ static int import_handle_text(int dataset, int parent)
     setGraphicObjectProperty(t, __GO_TEXT_ARRAY_DIMENSIONS__, dims, jni_int_vector, 2);
     setGraphicObjectProperty(t, __GO_TEXT_STRINGS__, text, jni_string_vector, dims[0] * dims[1]);
     freeStringMatrix(textnode, text);
-
+    delete[] text;
     closeList6(dataset);
     return t;
 }
@@ -958,7 +959,7 @@ static int import_handle_legend(int dataset, int parent)
     setGraphicObjectProperty(legend, __GO_TEXT_ARRAY_DIMENSIONS__, dims, jni_int_vector, 2);
     setGraphicObjectProperty(legend, __GO_TEXT_STRINGS__, text, jni_string_vector, dims[0] * dims[1]);
     freeStringMatrix(textnode, text);
-
+    delete[] text;
     //links
 
     //to retore links we need to have the entire hierarchie loaded.
@@ -1472,6 +1473,7 @@ static int import_handle_label(int dataset, int uid)
     setGraphicObjectProperty(uid, __GO_TEXT_ARRAY_DIMENSIONS__, dims.data(), jni_int_vector, 2);
     setGraphicObjectProperty(uid, __GO_TEXT_STRINGS__, data, jni_string_vector, dims[0] * dims[1]);
     freeStringMatrix(node, data);
+    delete[] data;
 
     closeList6(dataset);
     return uid;