1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2007 - INRIA - Allan CORNET
4 *
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 *
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
13 *
14 */
15 #include <stdlib.h>
16 #include "freeArrayOfString.h"
17 #include "sci_malloc.h"
18 /*---------------------------------------------------------------------------*/
freeArrayOfString(char ** Str,int dim)19 BOOL freeArrayOfString(char **Str, int dim)
20 {
21 return freeArray((void**)Str, dim);
22 }
23 /*---------------------------------------------------------------------------*/
freeArrayOfWideString(wchar_t ** wcStr,int dim)24 BOOL freeArrayOfWideString(wchar_t **wcStr, int dim)
25 {
26 return freeArray((void**)wcStr, dim);
27 }
28 /*---------------------------------------------------------------------------*/
freeArray(void ** pArray,int dim)29 BOOL freeArray(void **pArray, int dim)
30 {
31 BOOL bRet = TRUE;
32
33 if (pArray)
34 {
35 int i = 0;
36 for (i = 0; i < dim; i++)
37 {
38 if (pArray[i])
39 {
40 FREE(pArray[i]);
41 pArray[i] = NULL;
42 }
43 else
44 {
45 bRet = FALSE;
46 }
47 }
48 FREE(pArray);
49 pArray = NULL;
50 return bRet;
51 }
52 else
53 {
54 return FALSE;
55 }
56 }
57 /*---------------------------------------------------------------------------*/