fix memory leaks
This commit is contained in:
parent
c5dc9a1d7e
commit
18fd1c6c26
|
@ -3282,12 +3282,13 @@ char *arithmetic_callback_function(void *param, char *name, int32_t colId) {
|
||||||
|
|
||||||
static void arithmetic_function(SQLFunctionCtx *pCtx) {
|
static void arithmetic_function(SQLFunctionCtx *pCtx) {
|
||||||
GET_RES_INFO(pCtx)->numOfRes += pCtx->size;
|
GET_RES_INFO(pCtx)->numOfRes += pCtx->size;
|
||||||
SArithmeticSupport *sas = (SArithmeticSupport *)pCtx->param[0].pz;
|
SArithmeticSupport *sas = (SArithmeticSupport *)pCtx->param[1].pz;
|
||||||
|
|
||||||
tSQLBinaryExprCalcTraverse(sas->pExpr->pBinExprInfo.pBinExpr, pCtx->size, pCtx->aOutputBuf, sas, pCtx->order,
|
tSQLBinaryExprCalcTraverse(sas->pExpr->pBinExprInfo.pBinExpr, pCtx->size, pCtx->aOutputBuf, sas, pCtx->order,
|
||||||
arithmetic_callback_function);
|
arithmetic_callback_function);
|
||||||
|
|
||||||
pCtx->aOutputBuf += pCtx->outputBytes * pCtx->size * GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
|
pCtx->aOutputBuf += pCtx->outputBytes * pCtx->size * GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
|
||||||
|
pCtx->param[1].pz = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arithmetic_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
static void arithmetic_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ void tVariantCreateFromBinary(tVariant *pVar, char *pz, uint32_t len, uint32_t t
|
||||||
|
|
||||||
void tVariantDestroy(tVariant *pV);
|
void tVariantDestroy(tVariant *pV);
|
||||||
|
|
||||||
void tVariantAssign(tVariant *pDst, tVariant *pSrc);
|
void tVariantAssign(tVariant *pDst, const tVariant *pSrc);
|
||||||
|
|
||||||
int32_t tVariantToString(tVariant *pVar, char *dst);
|
int32_t tVariantToString(tVariant *pVar, char *dst);
|
||||||
|
|
||||||
|
|
|
@ -2092,7 +2092,7 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, int64_t startQueryTimes
|
||||||
pCtx->ptsList = (int64_t *)(primaryColumnData + startOffset * TSDB_KEYSIZE);
|
pCtx->ptsList = (int64_t *)(primaryColumnData + startOffset * TSDB_KEYSIZE);
|
||||||
|
|
||||||
} else if (functionId == TSDB_FUNC_ARITHM) {
|
} else if (functionId == TSDB_FUNC_ARITHM) {
|
||||||
pCtx->param[0].pz = param;
|
pCtx->param[1].pz = param;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCtx->startOffset = startOffset;
|
pCtx->startOffset = startOffset;
|
||||||
|
@ -2180,15 +2180,17 @@ static int32_t setupQueryRuntimeEnv(SMeterObj *pMeterObj, SQuery *pQuery, SQuery
|
||||||
|
|
||||||
pCtx->order = pQuery->order.order;
|
pCtx->order = pQuery->order.order;
|
||||||
pCtx->functionId = pSqlFuncMsg->functionId;
|
pCtx->functionId = pSqlFuncMsg->functionId;
|
||||||
|
|
||||||
/*
|
|
||||||
* tricky: in case of char array parameters, we employ the shallow copy
|
|
||||||
* method and get the ownership of the char array, it later release the allocated memory if exists
|
|
||||||
*/
|
|
||||||
pCtx->numOfParams = pSqlFuncMsg->numOfParams;
|
pCtx->numOfParams = pSqlFuncMsg->numOfParams;
|
||||||
for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
|
for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
|
||||||
pCtx->param[j].nType = pSqlFuncMsg->arg[j].argType;
|
if (pSqlFuncMsg->arg[j].argType == TSDB_DATA_TYPE_BINARY ||
|
||||||
pCtx->param[j].i64Key = pSqlFuncMsg->arg[j].argValue.i64;
|
pSqlFuncMsg->arg[j].argType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
tVariantCreateFromBinary(&pCtx->param[j], pSqlFuncMsg->arg[j].argValue.pz,
|
||||||
|
pSqlFuncMsg->arg[j].argBytes, pSqlFuncMsg->arg[j].argType);
|
||||||
|
} else {
|
||||||
|
tVariantCreateFromBinary(&pCtx->param[j], (char*) &pSqlFuncMsg->arg[j].argValue.d,
|
||||||
|
pSqlFuncMsg->arg[j].argBytes, pSqlFuncMsg->arg[j].argType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the order information for top/bottom query
|
// set the order information for top/bottom query
|
||||||
|
|
|
@ -169,7 +169,7 @@ void tVariantDestroy(tVariant *pVar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tVariantAssign(tVariant *pDst, tVariant *pSrc) {
|
void tVariantAssign(tVariant *pDst, const tVariant *pSrc) {
|
||||||
if (pSrc == NULL || pDst == NULL) return;
|
if (pSrc == NULL || pDst == NULL) return;
|
||||||
|
|
||||||
*pDst = *pSrc;
|
*pDst = *pSrc;
|
||||||
|
|
Loading…
Reference in New Issue