uses freeArrayOfString
Allan CORNET [Fri, 30 Oct 2009 15:03:12 +0000 (16:03 +0100)]
scilab/modules/graphics/src/c/BasicAlgos.c
scilab/modules/output_stream/sci_gateway/cpp/sci_diary.cpp
scilab/modules/output_stream/src/c/msgstore.c
scilab/modules/string/sci_gateway/c/sci_code2str.c
scilab/modules/string/sci_gateway/c/sci_strindex.c

index ffc0799..925403f 100644 (file)
@@ -20,7 +20,7 @@
 #include "MALLOC.h"
 #include "core_math.h"
 #include "rendererBasicAlgos.h"
-
+#include "freeArrayOfString.h"
 /*------------------------------------------------------------------------*/
 double sciFindStPosMin( const double x[], int n )
 {
@@ -158,13 +158,7 @@ double * createNewArrayFromSource( int destSize, const double src[], int srcSize
 /*------------------------------------------------------------------------*/
 void destroyStringArray( char * src[], int nbStrings )
 {
-  int i ;
-  for ( i = 0 ; i < nbStrings ; i++ )
-  {
-    FREE( src[i] ) ;
-    src[i] = NULL ;
-  }
-  FREE( src ) ;
+       freeArrayOfString(src, nbStrings);
 }
 /*--------------------------------------------------------------------------*/
 void destroyCppString(char * string)
index 9f1e926..52faebd 100644 (file)
@@ -286,8 +286,7 @@ static int sci_diary_one_rhs(char *fname)
                                {
                                        if (wcFilenames)
                                        {
-                                               if (wcFilenames[0]) {FREE(wcFilenames[0]); wcFilenames[0] = NULL;}
-                                               FREE(wcFilenames); wcFilenames = NULL;
+                                               freeArrayOfWideString(wcFilenames, 1);
                                                Scierror(999,_("%s: error can not close diary.\n"),fname);
                                                return 0;
                                        }
index 0665fc8..ad8ebc2 100644 (file)
@@ -13,6 +13,7 @@
 #include "MALLOC.h"
 #include "stack-c.h"
 #include "msgstore.h"
+#include "freeArrayOfString.h"
 /*--------------------------------------------------------------------------*/ 
 #define MEM_LACK 3
 #define MAX_LINES 2
@@ -60,11 +61,9 @@ int C2F(msgstore)(char *str,int *n)
 /*--------------------------------------------------------------------------*/ 
 void C2F(freemsgtable)()
 {
-  int k;
-  for (k=0 ; k< msg_line_counter ; k++)
-    FREE(msg_buff[k]);
-  msg_line_counter=0;
-  err_n = 0;
+       freeArrayOfString(msg_buff, msg_line_counter);
+       msg_line_counter = 0;
+       err_n = 0;
 }
 /*--------------------------------------------------------------------------*/ 
 int C2F(lasterror)(char *fname, unsigned long fname_len)
index 2009966..d05ad25 100644 (file)
@@ -23,6 +23,7 @@
 #include "localization.h"
 #include "code2str.h"
 #include "Scierror.h"
+#include "freeArrayOfString.h"
 /*--------------------------------------------------------------------------*/
 int sci_code2str(char *fname,unsigned long fname_len)
 {
@@ -87,9 +88,7 @@ int sci_code2str(char *fname,unsigned long fname_len)
        C2F(putlhsvar)();
 
        /* free pointers */
-       if (Output_Matrix[0]) { FREE(Output_Matrix[0]); Output_Matrix[0]=NULL;}
-       if (Output_Matrix) {FREE(Output_Matrix); Output_Matrix=NULL; }
-    
+       freeArrayOfString(Output_Matrix, 1);
 
        return 0;
 }
index 2933d6a..357efca 100644 (file)
@@ -265,12 +265,7 @@ int sci_strindex(char *fname,unsigned long fname_len)
                }
 
                FREE(wStrings_Input1);
-               for(i = 0 ; i < m2n2 ; i++)
-               {
-                       FREE(wStrings_Input2[i]);
-               }
-               FREE(wStrings_Input2);
-
+               freeArrayOfWideString(wStrings_Input2, m2n2);
                freeArrayOfString(Strings_Input1,m1n1);
                freeArrayOfString(Strings_Input2,m2n2);