Replace MALLOC/FREE to malloc/free fot fix heap memory leak error on Win/VC++
This commit is contained in:
parent
100e46d95b
commit
e22184553a
2 changed files with 14 additions and 14 deletions
|
|
@ -32,7 +32,7 @@ SwigScilabStringToChar(void *_pvApiCtx, int _iVar, char *_pcValue, char *_fname)
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
_pstStrings = (char *)MALLOC(sizeof(char));
|
||||
_pstStrings = (char *)malloc(sizeof(char));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &_piLength, (char **)&_pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
|
|
@ -44,7 +44,7 @@ SwigScilabStringToChar(void *_pvApiCtx, int _iVar, char *_pcValue, char *_fname)
|
|||
}
|
||||
*_pcValue = _pstStrings[0];
|
||||
|
||||
FREE(_pstStrings);
|
||||
free(_pstStrings);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ SWIGINTERN int
|
|||
SwigScilabStringFromChar(void *_pvApiCtx, int _iVarOut, char _chValue) {
|
||||
SciErr sciErr;
|
||||
|
||||
char *pchValue = (char*)MALLOC(sizeof(char) * 2);
|
||||
char *pchValue = (char*)malloc(sizeof(char) * 2);
|
||||
pchValue[0] = _chValue;
|
||||
pchValue[1] = '\0';
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ SwigScilabStringFromChar(void *_pvApiCtx, int _iVarOut, char _chValue) {
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
FREE(pchValue);
|
||||
free(pchValue);
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ SwigScilabStringToCharPtr(void *_pvApiCtx, int _iVar, char *_pcValue, int _iLeng
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
pstStrings = (char *)MALLOC(sizeof(char) * (piLength + 1));
|
||||
pstStrings = (char *)malloc(sizeof(char) * (piLength + 1));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
|
|
@ -135,7 +135,7 @@ SwigScilabStringToCharPtr(void *_pvApiCtx, int _iVar, char *_pcValue, int _iLeng
|
|||
|
||||
strcpy(_pcValue, pstStrings);
|
||||
|
||||
FREE(pstStrings);
|
||||
free(pstStrings);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ SwigScilabStringToCharPtrAndSize(void *_pvApiCtx, int _iVar, char **_pcValue, si
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
_pstStrings = (char *)MALLOC(sizeof(char) * (piLength + 1));
|
||||
_pstStrings = (char *)malloc(sizeof(char) * (piLength + 1));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&_pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
|
|
@ -191,7 +191,7 @@ SwigScilabStringToCharPtrAndSize(void *_pvApiCtx, int _iVar, char **_pcValue, si
|
|||
*_pcValue = _pstStrings;
|
||||
}
|
||||
|
||||
FREE(_pstStrings);
|
||||
free(_pstStrings);
|
||||
|
||||
if (_piLength != NULL) {
|
||||
*_piLength = (size_t) piLength;
|
||||
|
|
@ -206,7 +206,7 @@ SwigScilabStringFromCharPtr(void *_pvApiCtx, int _iVarOut, const char *_pchValue
|
|||
SciErr sciErr;
|
||||
char **pstData = NULL;
|
||||
|
||||
pstData = (char **)MALLOC(sizeof(char *));
|
||||
pstData = (char **)malloc(sizeof(char *));
|
||||
pstData[0] = strdup(_pchValue);
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, Rhs + _iVarOut, 1, 1, (char **)pstData);
|
||||
|
|
@ -215,7 +215,7 @@ SwigScilabStringFromCharPtr(void *_pvApiCtx, int _iVarOut, const char *_pchValue
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
freeArrayOfString(pstData, 1);
|
||||
free(pstData[0]);
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
|
|
@ -226,7 +226,7 @@ SwigScilabStringFromCharPtrAndSize(void *_pvApiCtx, int _iVarOut, const char *_p
|
|||
SciErr sciErr;
|
||||
char **pstData = NULL;
|
||||
|
||||
pstData = (char **)MALLOC(sizeof(char *));
|
||||
pstData = (char **)malloc(sizeof(char *));
|
||||
pstData[0] = strdup(_pchValue);
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, Rhs + _iVarOut, 1, 1, (char **)pstData);
|
||||
|
|
@ -235,7 +235,7 @@ SwigScilabStringFromCharPtrAndSize(void *_pvApiCtx, int _iVarOut, const char *_p
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
FREE(pstData);
|
||||
free(pstData[0]);
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ SWIG_Scilab_NewMemberObj(void *_pvApiCtx, int _iVarOut, void *_ptr, int _sz, swi
|
|||
r = SWIG_PackData(r, _ptr, _sz);
|
||||
strcpy(r, _type->name);
|
||||
|
||||
pstData = (char **)MALLOC(sizeof(char *));
|
||||
pstData = (char **)malloc(sizeof(char *));
|
||||
pstData[0] = strdup(r);
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, Rhs + _iVarOut, 1, 1, (char **)pstData);
|
||||
|
|
@ -162,7 +162,7 @@ SWIG_Scilab_NewMemberObj(void *_pvApiCtx, int _iVarOut, void *_ptr, int _sz, swi
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
freeArrayOfString(pstData, 1);
|
||||
free(pstData[0]);
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue