提交 dcc30f42 编写于 作者: D dapan1121

add client check

上级 5662c96f
...@@ -289,7 +289,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp( ...@@ -289,7 +289,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(
jsize len = (*env)->GetArrayLength(env, jsql); jsize len = (*env)->GetArrayLength(env, jsql);
char *str = (char *) calloc(1, sizeof(char) * (len + 1)); char *str = (char *) TDMCALLOC(1, sizeof(char) * (len + 1));
if (str == NULL) { if (str == NULL) {
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon); jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
return JNI_OUT_OF_MEMORY; return JNI_OUT_OF_MEMORY;
...@@ -651,7 +651,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab ...@@ -651,7 +651,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
jsize len = (*env)->GetArrayLength(env, jsql); jsize len = (*env)->GetArrayLength(env, jsql);
char *str = (char *)calloc(1, sizeof(char) * (len + 1)); char *str = (char *)TDMCALLOC(1, sizeof(char) * (len + 1));
(*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str); (*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str);
if ((*env)->ExceptionCheck(env)) { if ((*env)->ExceptionCheck(env)) {
// todo handle error // todo handle error
......
...@@ -52,7 +52,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para ...@@ -52,7 +52,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para
registerSqlObj(pSql); registerSqlObj(pSql);
pSql->sqlstr = calloc(1, sqlLen + 1); pSql->sqlstr = TDMCALLOC(1, sqlLen + 1);
if (pSql->sqlstr == NULL) { if (pSql->sqlstr == NULL) {
tscError("%p failed to malloc sql string buffer", pSql); tscError("%p failed to malloc sql string buffer", pSql);
pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY; pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -97,7 +97,7 @@ void taos_query_a(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *pa ...@@ -97,7 +97,7 @@ void taos_query_a(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *pa
nPrintTsc("%s", sqlstr); nPrintTsc("%s", sqlstr);
SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); SSqlObj *pSql = (SSqlObj *)TDMCALLOC(1, sizeof(SSqlObj));
if (pSql == NULL) { if (pSql == NULL) {
tscError("failed to malloc sqlObj"); tscError("failed to malloc sqlObj");
tscQueueAsyncError(fp, param, TSDB_CODE_TSC_OUT_OF_MEMORY); tscQueueAsyncError(fp, param, TSDB_CODE_TSC_OUT_OF_MEMORY);
...@@ -369,7 +369,7 @@ static void tscProcessAsyncError(SSchedMsg *pMsg) { ...@@ -369,7 +369,7 @@ static void tscProcessAsyncError(SSchedMsg *pMsg) {
} }
void tscQueueAsyncError(void(*fp), void *param, int32_t code) { void tscQueueAsyncError(void(*fp), void *param, int32_t code) {
int32_t* c = malloc(sizeof(int32_t)); int32_t* c = TDMALLOC(sizeof(int32_t));
*c = code; *c = code;
SSchedMsg schedMsg = { 0 }; SSchedMsg schedMsg = { 0 };
......
...@@ -280,7 +280,7 @@ void tscSCreateCallBack(void *param, TAOS_RES *tres, int code) { ...@@ -280,7 +280,7 @@ void tscSCreateCallBack(void *param, TAOS_RES *tres, int code) {
taos_fetch_rows_a(tres, tscSCreateCallBack, param); taos_fetch_rows_a(tres, tscSCreateCallBack, param);
builder->callStage = SCREATE_CALLBACK_RETRIEVE; builder->callStage = SCREATE_CALLBACK_RETRIEVE;
} else { } else {
char *result = calloc(1, TSDB_MAX_BINARY_LEN); char *result = TDMCALLOC(1, TSDB_MAX_BINARY_LEN);
pRes->code = builder->fp(builder, result); pRes->code = builder->fp(builder, result);
taos_free_result(pSql); taos_free_result(pSql);
...@@ -454,7 +454,7 @@ int32_t tscRebuildCreateTableStatement(void *param,char *result) { ...@@ -454,7 +454,7 @@ int32_t tscRebuildCreateTableStatement(void *param,char *result) {
SCreateBuilder *builder = (SCreateBuilder *)param; SCreateBuilder *builder = (SCreateBuilder *)param;
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
char *buf = calloc(1,TSDB_MAX_BINARY_LEN); char *buf = TDMCALLOC(1,TSDB_MAX_BINARY_LEN);
if (buf == NULL) { if (buf == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -512,7 +512,7 @@ int32_t tscRebuildCreateDBStatement(void *param,char *result) { ...@@ -512,7 +512,7 @@ int32_t tscRebuildCreateDBStatement(void *param,char *result) {
SCreateBuilder *builder = (SCreateBuilder *)param; SCreateBuilder *builder = (SCreateBuilder *)param;
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
char *buf = calloc(1, TSDB_MAX_BINARY_LEN); char *buf = TDMCALLOC(1, TSDB_MAX_BINARY_LEN);
if (buf == NULL) { if (buf == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -525,7 +525,7 @@ int32_t tscRebuildCreateDBStatement(void *param,char *result) { ...@@ -525,7 +525,7 @@ int32_t tscRebuildCreateDBStatement(void *param,char *result) {
} }
static int32_t tscGetTableTagColumnName(SSqlObj *pSql, char **result) { static int32_t tscGetTableTagColumnName(SSqlObj *pSql, char **result) {
char *buf = (char *)malloc(TSDB_MAX_BINARY_LEN); char *buf = (char *)TDMALLOC(TSDB_MAX_BINARY_LEN);
if (buf == NULL) { if (buf == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -557,12 +557,12 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch ...@@ -557,12 +557,12 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
STableMeta * pMeta = pTableMetaInfo->pTableMeta; STableMeta * pMeta = pTableMetaInfo->pTableMeta;
SSqlObj *pInterSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); SSqlObj *pInterSql = (SSqlObj *)TDMCALLOC(1, sizeof(SSqlObj));
if (pInterSql == NULL) { if (pInterSql == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
SCreateBuilder *param = (SCreateBuilder *)malloc(sizeof(SCreateBuilder)); SCreateBuilder *param = (SCreateBuilder *)TDMALLOC(sizeof(SCreateBuilder));
if (param == NULL) { if (param == NULL) {
TDMFREE(pInterSql); TDMFREE(pInterSql);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -579,7 +579,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch ...@@ -579,7 +579,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
param->fp = tscRebuildCreateTableStatement; param->fp = tscRebuildCreateTableStatement;
param->callStage = SCREATE_CALLBACK_QUERY; param->callStage = SCREATE_CALLBACK_QUERY;
char *query = (char *)calloc(1, TSDB_MAX_BINARY_LEN); char *query = (char *)TDMCALLOC(1, TSDB_MAX_BINARY_LEN);
if (query == NULL) { if (query == NULL) {
TDMFREE(param); TDMFREE(param);
TDMFREE(pInterSql); TDMFREE(pInterSql);
...@@ -678,7 +678,7 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) { ...@@ -678,7 +678,7 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) {
char tableName[TSDB_TABLE_NAME_LEN] = {0}; char tableName[TSDB_TABLE_NAME_LEN] = {0};
extractTableName(pTableMetaInfo->name, tableName); extractTableName(pTableMetaInfo->name, tableName);
char *result = (char *)calloc(1, TSDB_MAX_BINARY_LEN); char *result = (char *)TDMCALLOC(1, TSDB_MAX_BINARY_LEN);
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
code = tscRebuildDDLForSuperTable(pSql, tableName, result); code = tscRebuildDDLForSuperTable(pSql, tableName, result);
...@@ -702,12 +702,12 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) { ...@@ -702,12 +702,12 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) {
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
SSqlObj *pInterSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); SSqlObj *pInterSql = (SSqlObj *)TDMCALLOC(1, sizeof(SSqlObj));
if (pInterSql == NULL) { if (pInterSql == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
SCreateBuilder *param = (SCreateBuilder *)malloc(sizeof(SCreateBuilder)); SCreateBuilder *param = (SCreateBuilder *)TDMALLOC(sizeof(SCreateBuilder));
if (param == NULL) { if (param == NULL) {
TDMFREE(pInterSql); TDMFREE(pInterSql);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -729,7 +729,7 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) { ...@@ -729,7 +729,7 @@ static int32_t tscProcessCurrentUser(SSqlObj *pSql) {
pExpr->resBytes = TSDB_USER_LEN + TSDB_DATA_TYPE_BINARY; pExpr->resBytes = TSDB_USER_LEN + TSDB_DATA_TYPE_BINARY;
pExpr->resType = TSDB_DATA_TYPE_BINARY; pExpr->resType = TSDB_DATA_TYPE_BINARY;
char* vx = calloc(1, pExpr->resBytes); char* vx = TDMCALLOC(1, pExpr->resBytes);
if (vx == NULL) { if (vx == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -755,7 +755,7 @@ static int32_t tscProcessCurrentDB(SSqlObj *pSql) { ...@@ -755,7 +755,7 @@ static int32_t tscProcessCurrentDB(SSqlObj *pSql) {
size_t t = strlen(db); size_t t = strlen(db);
pExpr->resBytes = TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE; pExpr->resBytes = TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE;
char* vx = calloc(1, pExpr->resBytes); char* vx = TDMCALLOC(1, pExpr->resBytes);
if (vx == NULL) { if (vx == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -782,7 +782,7 @@ static int32_t tscProcessServerVer(SSqlObj *pSql) { ...@@ -782,7 +782,7 @@ static int32_t tscProcessServerVer(SSqlObj *pSql) {
size_t t = strlen(v); size_t t = strlen(v);
pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE); pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE);
char* vx = calloc(1, pExpr->resBytes); char* vx = TDMCALLOC(1, pExpr->resBytes);
if (vx == NULL) { if (vx == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -805,7 +805,7 @@ static int32_t tscProcessClientVer(SSqlObj *pSql) { ...@@ -805,7 +805,7 @@ static int32_t tscProcessClientVer(SSqlObj *pSql) {
size_t t = strlen(version); size_t t = strlen(version);
pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE); pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE);
char* v = calloc(1, pExpr->resBytes); char* v = TDMCALLOC(1, pExpr->resBytes);
if (v == NULL) { if (v == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
......
...@@ -104,13 +104,13 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc ...@@ -104,13 +104,13 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
} }
pCtx->interBufBytes = pExpr->interBytes; pCtx->interBufBytes = pExpr->interBytes;
pCtx->resultInfo = calloc(1, pCtx->interBufBytes + sizeof(SResultRowCellInfo)); pCtx->resultInfo = TDMCALLOC(1, pCtx->interBufBytes + sizeof(SResultRowCellInfo));
pCtx->stableQuery = true; pCtx->stableQuery = true;
} }
int16_t n = 0; int16_t n = 0;
int16_t tagLen = 0; int16_t tagLen = 0;
SQLFunctionCtx **pTagCtx = calloc(pQueryInfo->fieldsInfo.numOfOutput, POINTER_BYTES); SQLFunctionCtx **pTagCtx = TDMCALLOC(pQueryInfo->fieldsInfo.numOfOutput, POINTER_BYTES);
SQLFunctionCtx *pCtx = NULL; SQLFunctionCtx *pCtx = NULL;
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
...@@ -136,7 +136,7 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) { ...@@ -136,7 +136,7 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) {
int32_t numOfCols = (int32_t)tscNumOfFields(pQueryInfo); int32_t numOfCols = (int32_t)tscNumOfFields(pQueryInfo);
int32_t offset = 0; int32_t offset = 0;
SFillColInfo* pFillCol = calloc(numOfCols, sizeof(SFillColInfo)); SFillColInfo* pFillCol = TDMCALLOC(numOfCols, sizeof(SFillColInfo));
for(int32_t i = 0; i < numOfCols; ++i) { for(int32_t i = 0; i < numOfCols; ++i) {
SInternalField* pIField = taosArrayGet(pQueryInfo->fieldsInfo.internalField, i); SInternalField* pIField = taosArrayGet(pQueryInfo->fieldsInfo.internalField, i);
...@@ -214,7 +214,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd ...@@ -214,7 +214,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
size_t size = sizeof(SLocalReducer) + POINTER_BYTES * numOfFlush; size_t size = sizeof(SLocalReducer) + POINTER_BYTES * numOfFlush;
SLocalReducer *pReducer = (SLocalReducer *) calloc(1, size); SLocalReducer *pReducer = (SLocalReducer *) TDMCALLOC(1, size);
if (pReducer == NULL) { if (pReducer == NULL) {
tscError("%p failed to create local merge structure, out of memory", pSql); tscError("%p failed to create local merge structure, out of memory", pSql);
...@@ -238,7 +238,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd ...@@ -238,7 +238,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
int32_t numOfFlushoutInFile = pMemBuffer[i]->fileMeta.flushoutData.nLength; int32_t numOfFlushoutInFile = pMemBuffer[i]->fileMeta.flushoutData.nLength;
for (int32_t j = 0; j < numOfFlushoutInFile; ++j) { for (int32_t j = 0; j < numOfFlushoutInFile; ++j) {
SLocalDataSource *ds = (SLocalDataSource *)malloc(sizeof(SLocalDataSource) + pMemBuffer[0]->pageSize); SLocalDataSource *ds = (SLocalDataSource *)TDMALLOC(sizeof(SLocalDataSource) + pMemBuffer[0]->pageSize);
if (ds == NULL) { if (ds == NULL) {
tscError("%p failed to create merge structure", pSql); tscError("%p failed to create merge structure", pSql);
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -285,7 +285,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd ...@@ -285,7 +285,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer->numOfBuffer = idx; pReducer->numOfBuffer = idx;
SCompareParam *param = malloc(sizeof(SCompareParam)); SCompareParam *param = TDMALLOC(sizeof(SCompareParam));
if (param == NULL) { if (param == NULL) {
TDMFREE(pReducer); TDMFREE(pReducer);
return; return;
...@@ -308,7 +308,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd ...@@ -308,7 +308,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
// the input data format follows the old format, but output in a new format. // the input data format follows the old format, but output in a new format.
// so, all the input must be parsed as old format // so, all the input must be parsed as old format
pReducer->pCtx = (SQLFunctionCtx *)calloc(tscSqlExprNumOfExprs(pQueryInfo), sizeof(SQLFunctionCtx)); pReducer->pCtx = (SQLFunctionCtx *)TDMCALLOC(tscSqlExprNumOfExprs(pQueryInfo), sizeof(SQLFunctionCtx));
pReducer->rowSize = pMemBuffer[0]->nElemSize; pReducer->rowSize = pMemBuffer[0]->nElemSize;
tscRestoreSQLFuncForSTableQuery(pQueryInfo); tscRestoreSQLFuncForSTableQuery(pQueryInfo);
...@@ -321,15 +321,15 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd ...@@ -321,15 +321,15 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer->hasPrevRow = false; pReducer->hasPrevRow = false;
pReducer->hasUnprocessedRow = false; pReducer->hasUnprocessedRow = false;
pReducer->prevRowOfInput = (char *)calloc(1, pReducer->rowSize); pReducer->prevRowOfInput = (char *)TDMCALLOC(1, pReducer->rowSize);
// used to keep the latest input row // used to keep the latest input row
pReducer->pTempBuffer = (tFilePage *)calloc(1, pReducer->rowSize + sizeof(tFilePage)); pReducer->pTempBuffer = (tFilePage *)TDMCALLOC(1, pReducer->rowSize + sizeof(tFilePage));
pReducer->discardData = (tFilePage *)calloc(1, pReducer->rowSize + sizeof(tFilePage)); pReducer->discardData = (tFilePage *)TDMCALLOC(1, pReducer->rowSize + sizeof(tFilePage));
pReducer->discard = false; pReducer->discard = false;
pReducer->nResultBufSize = pMemBuffer[0]->pageSize * 16; pReducer->nResultBufSize = pMemBuffer[0]->pageSize * 16;
pReducer->pResultBuf = (tFilePage *)calloc(1, pReducer->nResultBufSize + sizeof(tFilePage)); pReducer->pResultBuf = (tFilePage *)TDMCALLOC(1, pReducer->nResultBufSize + sizeof(tFilePage));
pReducer->resColModel = finalmodel; pReducer->resColModel = finalmodel;
pReducer->resColModel->capacity = pReducer->nResultBufSize; pReducer->resColModel->capacity = pReducer->nResultBufSize;
...@@ -340,7 +340,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd ...@@ -340,7 +340,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
} }
assert(finalmodel->rowSize > 0 && finalmodel->rowSize <= pReducer->rowSize); assert(finalmodel->rowSize > 0 && finalmodel->rowSize <= pReducer->rowSize);
pReducer->pFinalRes = calloc(1, pReducer->rowSize * pReducer->resColModel->capacity); pReducer->pFinalRes = TDMCALLOC(1, pReducer->rowSize * pReducer->resColModel->capacity);
if (pReducer->pTempBuffer == NULL || pReducer->discardData == NULL || pReducer->pResultBuf == NULL || if (pReducer->pTempBuffer == NULL || pReducer->discardData == NULL || pReducer->pResultBuf == NULL ||
pReducer->pFinalRes == NULL || pReducer->prevRowOfInput == NULL) { pReducer->pFinalRes == NULL || pReducer->prevRowOfInput == NULL) {
...@@ -553,7 +553,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm ...@@ -553,7 +553,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
numOfGroupByCols++; numOfGroupByCols++;
} }
int32_t *orderColIndexList = (int32_t *)calloc(numOfGroupByCols, sizeof(int32_t)); int32_t *orderColIndexList = (int32_t *)TDMCALLOC(numOfGroupByCols, sizeof(int32_t));
if (orderColIndexList == NULL) { if (orderColIndexList == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -659,7 +659,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr ...@@ -659,7 +659,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
(*pMemBuffer) = (tExtMemBuffer **)malloc(POINTER_BYTES * pSql->subState.numOfSub); (*pMemBuffer) = (tExtMemBuffer **)TDMALLOC(POINTER_BYTES * pSql->subState.numOfSub);
if (*pMemBuffer == NULL) { if (*pMemBuffer == NULL) {
tscError("%p failed to allocate memory", pSql); tscError("%p failed to allocate memory", pSql);
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -668,7 +668,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr ...@@ -668,7 +668,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
size_t size = tscSqlExprNumOfExprs(pQueryInfo); size_t size = tscSqlExprNumOfExprs(pQueryInfo);
pSchema = (SSchema *)calloc(1, sizeof(SSchema) * size); pSchema = (SSchema *)TDMCALLOC(1, sizeof(SSchema) * size);
if (pSchema == NULL) { if (pSchema == NULL) {
tscError("%p failed to allocate memory", pSql); tscError("%p failed to allocate memory", pSql);
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -950,10 +950,10 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO ...@@ -950,10 +950,10 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
// todo extract function // todo extract function
int64_t actualETime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey; int64_t actualETime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey;
tFilePage **pResPages = malloc(POINTER_BYTES * pQueryInfo->fieldsInfo.numOfOutput); tFilePage **pResPages = TDMALLOC(POINTER_BYTES * pQueryInfo->fieldsInfo.numOfOutput);
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
pResPages[i] = calloc(1, sizeof(tFilePage) + pField->bytes * pLocalReducer->resColModel->capacity); pResPages[i] = TDMCALLOC(1, sizeof(tFilePage) + pField->bytes * pLocalReducer->resColModel->capacity);
} }
while (1) { while (1) {
...@@ -1134,7 +1134,7 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo ...@@ -1134,7 +1134,7 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
assert(maxBufSize >= 0); assert(maxBufSize >= 0);
char *buf = malloc((size_t)maxBufSize); char *buf = TDMALLOC((size_t)maxBufSize);
for (int32_t k = 0; k < size; ++k) { for (int32_t k = 0; k < size; ++k) {
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[k]; SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[k];
if (pCtx->functionId != TSDB_FUNC_TAG) { if (pCtx->functionId != TSDB_FUNC_TAG) {
...@@ -1608,14 +1608,14 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen) ...@@ -1608,14 +1608,14 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen)
pRes->row = 0; pRes->row = 0;
pRes->rspType = 0; // used as a flag to denote if taos_retrieved() has been called yet pRes->rspType = 0; // used as a flag to denote if taos_retrieved() has been called yet
pRes->pLocalReducer = (SLocalReducer *)calloc(1, sizeof(SLocalReducer)); pRes->pLocalReducer = (SLocalReducer *)TDMCALLOC(1, sizeof(SLocalReducer));
/* /*
* we need one additional byte space * we need one additional byte space
* the sprintf function needs one additional space to put '\0' at the end of string * the sprintf function needs one additional space to put '\0' at the end of string
*/ */
size_t allocSize = numOfRes * rowLen + sizeof(tFilePage) + 1; size_t allocSize = numOfRes * rowLen + sizeof(tFilePage) + 1;
pRes->pLocalReducer->pResultBuf = (tFilePage *)calloc(1, allocSize); pRes->pLocalReducer->pResultBuf = (tFilePage *)TDMCALLOC(1, allocSize);
pRes->pLocalReducer->pResultBuf->num = numOfRes; pRes->pLocalReducer->pResultBuf->num = numOfRes;
pRes->data = pRes->pLocalReducer->pResultBuf->data; pRes->data = pRes->pLocalReducer->pResultBuf->data;
...@@ -1623,7 +1623,7 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen) ...@@ -1623,7 +1623,7 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen)
int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) { int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) {
int32_t maxRowSize = MAX(rowSize, finalRowSize); int32_t maxRowSize = MAX(rowSize, finalRowSize);
char* pbuf = calloc(1, (size_t)(pOutput->num * maxRowSize)); char* pbuf = TDMCALLOC(1, (size_t)(pOutput->num * maxRowSize));
size_t size = tscNumOfFields(pQueryInfo); size_t size = tscNumOfFields(pQueryInfo);
SArithmeticSupport arithSup = {0}; SArithmeticSupport arithSup = {0};
...@@ -1632,7 +1632,7 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_ ...@@ -1632,7 +1632,7 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
arithSup.offset = 0; arithSup.offset = 0;
arithSup.numOfCols = (int32_t) tscSqlExprNumOfExprs(pQueryInfo); arithSup.numOfCols = (int32_t) tscSqlExprNumOfExprs(pQueryInfo);
arithSup.exprList = pQueryInfo->exprList; arithSup.exprList = pQueryInfo->exprList;
arithSup.data = calloc(arithSup.numOfCols, POINTER_BYTES); arithSup.data = TDMCALLOC(arithSup.numOfCols, POINTER_BYTES);
for(int32_t k = 0; k < arithSup.numOfCols; ++k) { for(int32_t k = 0; k < arithSup.numOfCols; ++k) {
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, k); SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, k);
......
...@@ -624,7 +624,7 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3 ...@@ -624,7 +624,7 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3
remain = pDataBlock->nAllocSize - pDataBlock->size; remain = pDataBlock->nAllocSize - pDataBlock->size;
} }
char *tmp = realloc(pDataBlock->pData, (size_t)pDataBlock->nAllocSize); char *tmp = TDMREALLOC(pDataBlock->pData, (size_t)pDataBlock->nAllocSize);
if (tmp != NULL) { if (tmp != NULL) {
pDataBlock->pData = tmp; pDataBlock->pData = tmp;
memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size); memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size);
...@@ -715,7 +715,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, SParsedDataColI ...@@ -715,7 +715,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, SParsedDataColI
} }
int32_t code = TSDB_CODE_TSC_INVALID_SQL; int32_t code = TSDB_CODE_TSC_INVALID_SQL;
char * tmpTokenBuf = calloc(1, 16*1024); // used for deleting Escape character: \\, \', \" char * tmpTokenBuf = TDMCALLOC(1, 16*1024); // used for deleting Escape character: \\, \', \"
if (NULL == tmpTokenBuf) { if (NULL == tmpTokenBuf) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -950,7 +950,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { ...@@ -950,7 +950,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
tdSortKVRowByColIdx(row); tdSortKVRowByColIdx(row);
pCmd->tagData.dataLen = kvRowLen(row); pCmd->tagData.dataLen = kvRowLen(row);
char* pTag = realloc(pCmd->tagData.data, pCmd->tagData.dataLen); char* pTag = TDMREALLOC(pCmd->tagData.data, pCmd->tagData.dataLen);
if (pTag == NULL) { if (pTag == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -1476,7 +1476,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) { ...@@ -1476,7 +1476,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
} }
tscAllocateMemIfNeed(pTableDataBlock, tinfo.rowSize, &maxRows); tscAllocateMemIfNeed(pTableDataBlock, tinfo.rowSize, &maxRows);
char *tokenBuf = calloc(1, 4096); char *tokenBuf = TDMCALLOC(1, 4096);
while ((readLen = tgetline(&line, &n, fp)) != -1) { while ((readLen = tgetline(&line, &n, fp)) != -1) {
if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) { if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) {
...@@ -1535,7 +1535,7 @@ void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) { ...@@ -1535,7 +1535,7 @@ void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) {
assert(pCmd->dataSourceType == DATA_FROM_DATA_FILE && strlen(pCmd->payload) != 0); assert(pCmd->dataSourceType == DATA_FROM_DATA_FILE && strlen(pCmd->payload) != 0);
SImportFileSupport *pSupporter = calloc(1, sizeof(SImportFileSupport)); SImportFileSupport *pSupporter = TDMCALLOC(1, sizeof(SImportFileSupport));
SSqlObj *pNew = createSubqueryObj(pSql, 0, parseFileSendDataBlock, pSupporter, TSDB_SQL_INSERT, NULL); SSqlObj *pNew = createSubqueryObj(pSql, 0, parseFileSendDataBlock, pSupporter, TSDB_SQL_INSERT, NULL);
pCmd->count = 1; pCmd->count = 1;
......
...@@ -54,7 +54,7 @@ static int normalStmtAddPart(SNormalStmt* stmt, bool isParam, char* str, uint32_ ...@@ -54,7 +54,7 @@ static int normalStmtAddPart(SNormalStmt* stmt, bool isParam, char* str, uint32_
uint16_t size = stmt->numParts + 1; uint16_t size = stmt->numParts + 1;
if (size > stmt->sizeParts) { if (size > stmt->sizeParts) {
size *= 2; size *= 2;
void* tmp = realloc(stmt->parts, sizeof(SNormalStmtPart) * size); void* tmp = TDMREALLOC(stmt->parts, sizeof(SNormalStmtPart) * size);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -125,7 +125,7 @@ static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { ...@@ -125,7 +125,7 @@ static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
var->pz = (char*)malloc((*tb->length) + 1); var->pz = (char*)TDMALLOC((*tb->length) + 1);
if (var->pz == NULL) { if (var->pz == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -179,7 +179,7 @@ static int normalStmtPrepare(STscStmt* stmt) { ...@@ -179,7 +179,7 @@ static int normalStmtPrepare(STscStmt* stmt) {
} }
if (normal->numParams > 0) { if (normal->numParams > 0) {
normal->params = calloc(normal->numParams, sizeof(tVariant)); normal->params = TDMCALLOC(normal->numParams, sizeof(tVariant));
if (normal->params == NULL) { if (normal->params == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -714,7 +714,7 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { ...@@ -714,7 +714,7 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
totalDataSize += dataSize + sizeof(SSubmitBlk); totalDataSize += dataSize + sizeof(SSubmitBlk);
if (totalDataSize > pBlock->nAllocSize) { if (totalDataSize > pBlock->nAllocSize) {
const double factor = 1.5; const double factor = 1.5;
void* tmp = realloc(pBlock->pData, (uint32_t)(totalDataSize * factor)); void* tmp = TDMREALLOC(pBlock->pData, (uint32_t)(totalDataSize * factor));
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -850,7 +850,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { ...@@ -850,7 +850,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
return NULL; return NULL;
} }
STscStmt* pStmt = calloc(1, sizeof(STscStmt)); STscStmt* pStmt = TDMCALLOC(1, sizeof(STscStmt));
if (pStmt == NULL) { if (pStmt == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
tscError("failed to allocate memory for statement"); tscError("failed to allocate memory for statement");
...@@ -858,7 +858,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { ...@@ -858,7 +858,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
} }
pStmt->taos = pObj; pStmt->taos = pObj;
SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); SSqlObj* pSql = TDMCALLOC(1, sizeof(SSqlObj));
if (pSql == NULL) { if (pSql == NULL) {
TDMFREE(pStmt); TDMFREE(pStmt);
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -897,7 +897,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { ...@@ -897,7 +897,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1); pSql->sqlstr = TDMREALLOC(pSql->sqlstr, sqlLen + 1);
if (pSql->sqlstr == NULL) { if (pSql->sqlstr == NULL) {
tscError("%p failed to malloc sql string buffer", pSql); tscError("%p failed to malloc sql string buffer", pSql);
......
...@@ -102,7 +102,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) { ...@@ -102,7 +102,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) {
tscDebug("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr); tscDebug("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr);
int32_t sqlSize = (int32_t)(TSDB_SLOW_QUERY_SQL_LEN + size); int32_t sqlSize = (int32_t)(TSDB_SLOW_QUERY_SQL_LEN + size);
char *sql = malloc(sqlSize); char *sql = TDMALLOC(sqlSize);
if (sql == NULL) { if (sql == NULL) {
tscError("%p failed to allocate memory to sent slow query to dnode", pSql); tscError("%p failed to allocate memory to sent slow query to dnode", pSql);
return; return;
......
...@@ -1386,7 +1386,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t ...@@ -1386,7 +1386,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, slot); SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, slot);
if (pInfo->pSqlExpr == NULL) { if (pInfo->pSqlExpr == NULL) {
SExprInfo* pArithExprInfo = calloc(1, sizeof(SExprInfo)); SExprInfo* pArithExprInfo = TDMCALLOC(1, sizeof(SExprInfo));
// arithmetic expression always return result in the format of double float // arithmetic expression always return result in the format of double float
pArithExprInfo->bytes = sizeof(double); pArithExprInfo->bytes = sizeof(double);
...@@ -2980,7 +2980,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) { ...@@ -2980,7 +2980,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumn* pColumn) {
int32_t size = pColumn->numOfFilters + 1; int32_t size = pColumn->numOfFilters + 1;
char* tmp = (char*) realloc((void*)(pColumn->filterInfo), sizeof(SColumnFilterInfo) * (size)); char* tmp = (char*) TDMREALLOC((void*)(pColumn->filterInfo), sizeof(SColumnFilterInfo) * (size));
if (tmp != NULL) { if (tmp != NULL) {
pColumn->filterInfo = (SColumnFilterInfo*)tmp; pColumn->filterInfo = (SColumnFilterInfo*)tmp;
} else { } else {
...@@ -3022,13 +3022,13 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, ...@@ -3022,13 +3022,13 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
// TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd // TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd
} else if (colType == TSDB_DATA_TYPE_BINARY) { } else if (colType == TSDB_DATA_TYPE_BINARY) {
pColumnFilter->pz = (int64_t)calloc(1, pRight->val.nLen + TSDB_NCHAR_SIZE); pColumnFilter->pz = (int64_t)TDMCALLOC(1, pRight->val.nLen + TSDB_NCHAR_SIZE);
pColumnFilter->len = pRight->val.nLen; pColumnFilter->len = pRight->val.nLen;
retVal = tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false); retVal = tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false);
} else if (colType == TSDB_DATA_TYPE_NCHAR) { } else if (colType == TSDB_DATA_TYPE_NCHAR) {
// pRight->val.nLen + 1 is larger than the actual nchar string length // pRight->val.nLen + 1 is larger than the actual nchar string length
pColumnFilter->pz = (int64_t)calloc(1, (pRight->val.nLen + 1) * TSDB_NCHAR_SIZE); pColumnFilter->pz = (int64_t)TDMCALLOC(1, (pRight->val.nLen + 1) * TSDB_NCHAR_SIZE);
retVal = tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false); retVal = tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false);
size_t len = twcslen((wchar_t*)pColumnFilter->pz); size_t len = twcslen((wchar_t*)pColumnFilter->pz);
pColumnFilter->len = len * TSDB_NCHAR_SIZE; pColumnFilter->len = len * TSDB_NCHAR_SIZE;
...@@ -4494,7 +4494,7 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery ...@@ -4494,7 +4494,7 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery
size_t size = tscNumOfFields(pQueryInfo); size_t size = tscNumOfFields(pQueryInfo);
if (pQueryInfo->fillVal == NULL) { if (pQueryInfo->fillVal == NULL) {
pQueryInfo->fillVal = calloc(size, sizeof(int64_t)); pQueryInfo->fillVal = TDMCALLOC(size, sizeof(int64_t));
if (pQueryInfo->fillVal == NULL) { if (pQueryInfo->fillVal == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -4935,7 +4935,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -4935,7 +4935,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tVariantListItem* pItem = taosArrayGet(pVarList, 1); tVariantListItem* pItem = taosArrayGet(pVarList, 1);
SSchema* pTagsSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex.columnIndex); SSchema* pTagsSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex.columnIndex);
pAlterSQL->tagData.data = calloc(1, pTagsSchema->bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); pAlterSQL->tagData.data = TDMCALLOC(1, pTagsSchema->bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE);
if (tVariantDump(&pItem->pVar, pAlterSQL->tagData.data, pTagsSchema->type, true) != TSDB_CODE_SUCCESS) { if (tVariantDump(&pItem->pVar, pAlterSQL->tagData.data, pTagsSchema->type, true) != TSDB_CODE_SUCCESS) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg13); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg13);
...@@ -6268,7 +6268,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { ...@@ -6268,7 +6268,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
pTag->dataLen = kvRowLen(row); pTag->dataLen = kvRowLen(row);
if (pTag->data == NULL) { if (pTag->data == NULL) {
pTag->data = malloc(pTag->dataLen); pTag->data = TDMALLOC(pTag->dataLen);
} }
kvRowCpy(pTag->data, row); kvRowCpy(pTag->data, row);
...@@ -6676,23 +6676,23 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS ...@@ -6676,23 +6676,23 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS
} }
if (pSqlExpr->pLeft == NULL && pSqlExpr->pRight == NULL && pSqlExpr->nSQLOptr == 0) { if (pSqlExpr->pLeft == NULL && pSqlExpr->pRight == NULL && pSqlExpr->nSQLOptr == 0) {
*pExpr = calloc(1, sizeof(tExprNode)); *pExpr = TDMCALLOC(1, sizeof(tExprNode));
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (pSqlExpr->pLeft == NULL) { if (pSqlExpr->pLeft == NULL) {
if (pSqlExpr->nSQLOptr >= TK_BOOL && pSqlExpr->nSQLOptr <= TK_STRING) { if (pSqlExpr->nSQLOptr >= TK_BOOL && pSqlExpr->nSQLOptr <= TK_STRING) {
*pExpr = calloc(1, sizeof(tExprNode)); *pExpr = TDMCALLOC(1, sizeof(tExprNode));
(*pExpr)->nodeType = TSQL_NODE_VALUE; (*pExpr)->nodeType = TSQL_NODE_VALUE;
(*pExpr)->pVal = calloc(1, sizeof(tVariant)); (*pExpr)->pVal = TDMCALLOC(1, sizeof(tVariant));
tVariantAssign((*pExpr)->pVal, &pSqlExpr->val); tVariantAssign((*pExpr)->pVal, &pSqlExpr->val);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else if (pSqlExpr->nSQLOptr >= TK_COUNT && pSqlExpr->nSQLOptr <= TK_AVG_IRATE) { } else if (pSqlExpr->nSQLOptr >= TK_COUNT && pSqlExpr->nSQLOptr <= TK_AVG_IRATE) {
// arithmetic expression on the results of aggregation functions // arithmetic expression on the results of aggregation functions
*pExpr = calloc(1, sizeof(tExprNode)); *pExpr = TDMCALLOC(1, sizeof(tExprNode));
(*pExpr)->nodeType = TSQL_NODE_COL; (*pExpr)->nodeType = TSQL_NODE_COL;
(*pExpr)->pSchema = calloc(1, sizeof(SSchema)); (*pExpr)->pSchema = TDMCALLOC(1, sizeof(SSchema));
strncpy((*pExpr)->pSchema->name, pSqlExpr->operand.z, pSqlExpr->operand.n); strncpy((*pExpr)->pSchema->name, pSqlExpr->operand.z, pSqlExpr->operand.n);
// set the input column data byte and type. // set the input column data byte and type.
...@@ -6723,9 +6723,9 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS ...@@ -6723,9 +6723,9 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS
STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta; STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta;
int32_t numOfColumns = tscGetNumOfColumns(pTableMeta); int32_t numOfColumns = tscGetNumOfColumns(pTableMeta);
*pExpr = calloc(1, sizeof(tExprNode)); *pExpr = TDMCALLOC(1, sizeof(tExprNode));
(*pExpr)->nodeType = TSQL_NODE_COL; (*pExpr)->nodeType = TSQL_NODE_COL;
(*pExpr)->pSchema = calloc(1, sizeof(SSchema)); (*pExpr)->pSchema = TDMCALLOC(1, sizeof(SSchema));
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex);
*(*pExpr)->pSchema = *pSchema; *(*pExpr)->pSchema = *pSchema;
...@@ -6746,7 +6746,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS ...@@ -6746,7 +6746,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS
} }
} else { } else {
*pExpr = (tExprNode *)calloc(1, sizeof(tExprNode)); *pExpr = (tExprNode *)TDMCALLOC(1, sizeof(tExprNode));
(*pExpr)->nodeType = TSQL_NODE_EXPR; (*pExpr)->nodeType = TSQL_NODE_EXPR;
(*pExpr)->_node.hasPK = false; (*pExpr)->_node.hasPK = false;
......
...@@ -152,7 +152,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) { ...@@ -152,7 +152,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) {
assert(pTableMetaMsg != NULL && pTableMetaMsg->numOfColumns >= 2 && pTableMetaMsg->numOfTags >= 0); assert(pTableMetaMsg != NULL && pTableMetaMsg->numOfColumns >= 2 && pTableMetaMsg->numOfTags >= 0);
int32_t schemaSize = (pTableMetaMsg->numOfColumns + pTableMetaMsg->numOfTags) * sizeof(SSchema); int32_t schemaSize = (pTableMetaMsg->numOfColumns + pTableMetaMsg->numOfTags) * sizeof(SSchema);
STableMeta* pTableMeta = calloc(1, sizeof(STableMeta) + schemaSize); STableMeta* pTableMeta = TDMCALLOC(1, sizeof(STableMeta) + schemaSize);
pTableMeta->tableType = pTableMetaMsg->tableType; pTableMeta->tableType = pTableMetaMsg->tableType;
pTableMeta->vgId = pTableMetaMsg->vgroup.vgId; pTableMeta->vgId = pTableMetaMsg->vgroup.vgId;
......
...@@ -201,7 +201,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) { ...@@ -201,7 +201,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
} }
if (pRes->length == NULL) { if (pRes->length == NULL) {
pRes->length = calloc(2, sizeof(int32_t)); pRes->length = TDMCALLOC(2, sizeof(int32_t));
} }
pRes->length[0] = total; pRes->length[0] = total;
...@@ -209,7 +209,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) { ...@@ -209,7 +209,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
} else { } else {
tscDebug("%" PRId64 " heartbeat failed, code:%s", pObj->hbrid, tstrerror(code)); tscDebug("%" PRId64 " heartbeat failed, code:%s", pObj->hbrid, tstrerror(code));
if (pRes->length == NULL) { if (pRes->length == NULL) {
pRes->length = calloc(2, sizeof(int32_t)); pRes->length = TDMCALLOC(2, sizeof(int32_t));
} }
pRes->length[1] = 0; pRes->length[1] = 0;
...@@ -386,7 +386,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { ...@@ -386,7 +386,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
pRes->rspLen = rpcMsg->contLen; pRes->rspLen = rpcMsg->contLen;
if (pRes->rspLen > 0 && rpcMsg->pCont) { if (pRes->rspLen > 0 && rpcMsg->pCont) {
char *tmp = (char *)realloc(pRes->pRsp, pRes->rspLen); char *tmp = (char *)TDMREALLOC(pRes->pRsp, pRes->rspLen);
if (tmp == NULL) { if (tmp == NULL) {
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
} else { } else {
...@@ -2026,7 +2026,7 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) { ...@@ -2026,7 +2026,7 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
size_t size = sizeof(SVgroupMsg) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsMsg); size_t size = sizeof(SVgroupMsg) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsMsg);
size_t vgroupsz = sizeof(SVgroupInfo) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsInfo); size_t vgroupsz = sizeof(SVgroupInfo) * pVgroupMsg->numOfVgroups + sizeof(SVgroupsInfo);
pInfo->vgroupList = calloc(1, vgroupsz); pInfo->vgroupList = TDMCALLOC(1, vgroupsz);
assert(pInfo->vgroupList != NULL); assert(pInfo->vgroupList != NULL);
pInfo->vgroupList->numOfVgroups = pVgroupMsg->numOfVgroups; pInfo->vgroupList->numOfVgroups = pVgroupMsg->numOfVgroups;
...@@ -2114,7 +2114,7 @@ static void createHBObj(STscObj* pObj) { ...@@ -2114,7 +2114,7 @@ static void createHBObj(STscObj* pObj) {
return; return;
} }
SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); SSqlObj *pSql = (SSqlObj *)TDMCALLOC(1, sizeof(SSqlObj));
if (NULL == pSql) return; if (NULL == pSql) return;
pSql->fp = tscProcessHeartBeatRsp; pSql->fp = tscProcessHeartBeatRsp;
...@@ -2304,7 +2304,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) { ...@@ -2304,7 +2304,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
void tscTableMetaCallBack(void *param, TAOS_RES *res, int code); void tscTableMetaCallBack(void *param, TAOS_RES *res, int code);
static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) { static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
SSqlObj *pNew = calloc(1, sizeof(SSqlObj)); SSqlObj *pNew = TDMCALLOC(1, sizeof(SSqlObj));
if (NULL == pNew) { if (NULL == pNew) {
tscError("%p malloc failed for new sqlobj to get table meta", pSql); tscError("%p malloc failed for new sqlobj to get table meta", pSql);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -2364,7 +2364,7 @@ int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) { ...@@ -2364,7 +2364,7 @@ int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
TDMFREE(pTableMetaInfo->pTableMeta); TDMFREE(pTableMetaInfo->pTableMeta);
uint32_t size = tscGetTableMetaMaxSize(); uint32_t size = tscGetTableMetaMaxSize();
pTableMetaInfo->pTableMeta = calloc(1, size); pTableMetaInfo->pTableMeta = TDMCALLOC(1, size);
pTableMetaInfo->pTableMeta->tableInfo.numOfColumns = -1; pTableMetaInfo->pTableMeta->tableInfo.numOfColumns = -1;
int32_t len = (int32_t) strlen(pTableMetaInfo->name); int32_t len = (int32_t) strlen(pTableMetaInfo->name);
...@@ -2437,7 +2437,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { ...@@ -2437,7 +2437,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SSqlObj *pNew = calloc(1, sizeof(SSqlObj)); SSqlObj *pNew = TDMCALLOC(1, sizeof(SSqlObj));
pNew->pTscObj = pSql->pTscObj; pNew->pTscObj = pSql->pTscObj;
pNew->signature = pNew; pNew->signature = pNew;
......
...@@ -97,14 +97,14 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa ...@@ -97,14 +97,14 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
return NULL; return NULL;
} }
STscObj *pObj = (STscObj *)calloc(1, sizeof(STscObj)); STscObj *pObj = (STscObj *)TDMCALLOC(1, sizeof(STscObj));
if (NULL == pObj) { if (NULL == pObj) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
rpcClose(pDnodeConn); rpcClose(pDnodeConn);
return NULL; return NULL;
} }
// set up tscObj's mgmtEpSet // set up tscObj's mgmtEpSet
pObj->tscCorMgmtEpSet = (SRpcCorEpSet *)malloc(sizeof(SRpcCorEpSet)); pObj->tscCorMgmtEpSet = (SRpcCorEpSet *)TDMALLOC(sizeof(SRpcCorEpSet));
if (NULL == pObj->tscCorMgmtEpSet) { if (NULL == pObj->tscCorMgmtEpSet) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
rpcClose(pDnodeConn); rpcClose(pDnodeConn);
...@@ -140,7 +140,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa ...@@ -140,7 +140,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
pthread_mutex_init(&pObj->mutex, NULL); pthread_mutex_init(&pObj->mutex, NULL);
SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); SSqlObj *pSql = (SSqlObj *)TDMCALLOC(1, sizeof(SSqlObj));
if (NULL == pSql) { if (NULL == pSql) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
rpcClose(pDnodeConn); rpcClose(pDnodeConn);
...@@ -329,7 +329,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, int64_t* ...@@ -329,7 +329,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, int64_t*
nPrintTsc("%s", sqlstr); nPrintTsc("%s", sqlstr);
SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); SSqlObj* pSql = TDMCALLOC(1, sizeof(SSqlObj));
if (pSql == NULL) { if (pSql == NULL) {
tscError("failed to malloc sqlObj"); tscError("failed to malloc sqlObj");
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -416,7 +416,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { ...@@ -416,7 +416,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
SFieldInfo *pFieldInfo = &pQueryInfo->fieldsInfo; SFieldInfo *pFieldInfo = &pQueryInfo->fieldsInfo;
if (pFieldInfo->final == NULL) { if (pFieldInfo->final == NULL) {
TAOS_FIELD* f = calloc(pFieldInfo->numOfOutput, sizeof(TAOS_FIELD)); TAOS_FIELD* f = TDMCALLOC(pFieldInfo->numOfOutput, sizeof(TAOS_FIELD));
int32_t j = 0; int32_t j = 0;
for(int32_t i = 0; i < pFieldInfo->numOfOutput; ++i) { for(int32_t i = 0; i < pFieldInfo->numOfOutput; ++i) {
...@@ -867,7 +867,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) { ...@@ -867,7 +867,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
return TSDB_CODE_TSC_DISCONNECTED; return TSDB_CODE_TSC_DISCONNECTED;
} }
SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); SSqlObj* pSql = TDMCALLOC(1, sizeof(SSqlObj));
pSql->pTscObj = taos; pSql->pTscObj = taos;
pSql->signature = pSql; pSql->signature = pSql;
...@@ -888,7 +888,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) { ...@@ -888,7 +888,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
return TSDB_CODE_TSC_EXCEED_SQL_LIMIT; return TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
} }
pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1); pSql->sqlstr = TDMREALLOC(pSql->sqlstr, sqlLen + 1);
if (pSql->sqlstr == NULL) { if (pSql->sqlstr == NULL) {
tscError("%p failed to malloc sql string buffer", pSql); tscError("%p failed to malloc sql string buffer", pSql);
tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pSql), pObj); tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pSql), pObj);
...@@ -985,7 +985,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t ...@@ -985,7 +985,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
} }
if (payloadLen + strlen(pTableMetaInfo->name) + 128 >= pCmd->allocSize) { if (payloadLen + strlen(pTableMetaInfo->name) + 128 >= pCmd->allocSize) {
char *pNewMem = realloc(pCmd->payload, pCmd->allocSize + tblListLen); char *pNewMem = TDMREALLOC(pCmd->payload, pCmd->allocSize + tblListLen);
if (pNewMem == NULL) { if (pNewMem == NULL) {
code = TSDB_CODE_TSC_OUT_OF_MEMORY; code = TSDB_CODE_TSC_OUT_OF_MEMORY;
sprintf(pCmd->payload, "failed to allocate memory"); sprintf(pCmd->payload, "failed to allocate memory");
...@@ -1015,7 +1015,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { ...@@ -1015,7 +1015,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
return TSDB_CODE_TSC_DISCONNECTED; return TSDB_CODE_TSC_DISCONNECTED;
} }
SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); SSqlObj* pSql = TDMCALLOC(1, sizeof(SSqlObj));
pSql->pTscObj = taos; pSql->pTscObj = taos;
pSql->signature = pSql; pSql->signature = pSql;
...@@ -1035,7 +1035,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { ...@@ -1035,7 +1035,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
char *str = calloc(1, tblListLen + 1); char *str = TDMCALLOC(1, tblListLen + 1);
if (str == NULL) { if (str == NULL) {
tscError("%p failed to malloc sql string buffer", pSql); tscError("%p failed to malloc sql string buffer", pSql);
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
......
...@@ -569,7 +569,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p ...@@ -569,7 +569,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
STscObj *pObj = (STscObj *)taos; STscObj *pObj = (STscObj *)taos;
if (pObj == NULL || pObj->signature != pObj) return NULL; if (pObj == NULL || pObj->signature != pObj) return NULL;
SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); SSqlObj *pSql = (SSqlObj *)TDMCALLOC(1, sizeof(SSqlObj));
if (pSql == NULL) { if (pSql == NULL) {
return NULL; return NULL;
} }
...@@ -580,7 +580,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p ...@@ -580,7 +580,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
SSqlRes *pRes = &pSql->res; SSqlRes *pRes = &pSql->res;
SSqlStream *pStream = (SSqlStream *)calloc(1, sizeof(SSqlStream)); SSqlStream *pStream = (SSqlStream *)TDMCALLOC(1, sizeof(SSqlStream));
if (pStream == NULL) { if (pStream == NULL) {
tscError("%p open stream failed, sql:%s, reason:%s, code:0x%08x", pSql, sqlstr, pCmd->payload, pRes->code); tscError("%p open stream failed, sql:%s, reason:%s, code:0x%08x", pSql, sqlstr, pCmd->payload, pRes->code);
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
...@@ -596,7 +596,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p ...@@ -596,7 +596,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
pSql->param = pStream; pSql->param = pStream;
pSql->maxRetry = TSDB_MAX_REPLICA; pSql->maxRetry = TSDB_MAX_REPLICA;
pSql->sqlstr = calloc(1, strlen(sqlstr) + 1); pSql->sqlstr = TDMCALLOC(1, strlen(sqlstr) + 1);
if (pSql->sqlstr == NULL) { if (pSql->sqlstr == NULL) {
tscError("%p failed to malloc sql string buffer", pSql); tscError("%p failed to malloc sql string buffer", pSql);
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
......
...@@ -96,7 +96,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* ...@@ -96,7 +96,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char*
int code = TSDB_CODE_SUCCESS, line = __LINE__; int code = TSDB_CODE_SUCCESS, line = __LINE__;
SSqlObj* pSql = NULL; SSqlObj* pSql = NULL;
SSub* pSub = calloc(1, sizeof(SSub)); SSub* pSub = TDMCALLOC(1, sizeof(SSub));
if (pSub == NULL) { if (pSub == NULL) {
line = __LINE__; line = __LINE__;
code = TSDB_CODE_TSC_OUT_OF_MEMORY; code = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -117,7 +117,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* ...@@ -117,7 +117,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char*
goto fail; goto fail;
} }
pSql = calloc(1, sizeof(SSqlObj)); pSql = TDMCALLOC(1, sizeof(SSqlObj));
if (pSql == NULL) { if (pSql == NULL) {
line = __LINE__; line = __LINE__;
code = TSDB_CODE_TSC_OUT_OF_MEMORY; code = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -423,7 +423,7 @@ TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char* topic, const char ...@@ -423,7 +423,7 @@ TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char* topic, const char
} }
SSqlObj* recreateSqlObj(SSub* pSub) { SSqlObj* recreateSqlObj(SSub* pSub) {
SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); SSqlObj* pSql = TDMCALLOC(1, sizeof(SSqlObj));
if (pSql == NULL) { if (pSql == NULL) {
return NULL; return NULL;
} }
......
...@@ -208,7 +208,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ ...@@ -208,7 +208,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
// todo handle failed to create sub query // todo handle failed to create sub query
SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) { SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
SJoinSupporter* pSupporter = calloc(1, sizeof(SJoinSupporter)); SJoinSupporter* pSupporter = TDMCALLOC(1, sizeof(SJoinSupporter));
if (pSupporter == NULL) { if (pSupporter == NULL) {
return NULL; return NULL;
} }
...@@ -802,7 +802,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow ...@@ -802,7 +802,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
size_t length = pSupporter->totalLen + validLen; size_t length = pSupporter->totalLen + validLen;
// todo handle memory error // todo handle memory error
char* tmp = realloc(pSupporter->pIdTagList, length); char* tmp = TDMREALLOC(pSupporter->pIdTagList, length);
if (tmp == NULL) { if (tmp == NULL) {
tscError("%p failed to malloc memory", pSql); tscError("%p failed to malloc memory", pSql);
...@@ -1324,7 +1324,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) { ...@@ -1324,7 +1324,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
int32_t numOfExprs = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); int32_t numOfExprs = (int32_t)tscSqlExprNumOfExprs(pQueryInfo);
pRes->pColumnIndex = calloc(1, sizeof(SColumnIndex) * numOfExprs); pRes->pColumnIndex = TDMCALLOC(1, sizeof(SColumnIndex) * numOfExprs);
if (pRes->pColumnIndex == NULL) { if (pRes->pColumnIndex == NULL) {
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
return; return;
...@@ -1455,7 +1455,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter ...@@ -1455,7 +1455,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
assert(pSql->res.numOfRows == 0); assert(pSql->res.numOfRows == 0);
if (pSql->pSubs == NULL) { if (pSql->pSubs == NULL) {
pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES); pSql->pSubs = TDMCALLOC(pSql->subState.numOfSub, POINTER_BYTES);
if (pSql->pSubs == NULL) { if (pSql->pSubs == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -1705,7 +1705,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { ...@@ -1705,7 +1705,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
return ret; return ret;
} }
pSql->pSubs = calloc(pState->numOfSub, POINTER_BYTES); pSql->pSubs = TDMCALLOC(pState->numOfSub, POINTER_BYTES);
tscDebug("%p retrieved query data from %d vnode(s)", pSql, pState->numOfSub); tscDebug("%p retrieved query data from %d vnode(s)", pSql, pState->numOfSub);
...@@ -1723,7 +1723,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { ...@@ -1723,7 +1723,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
int32_t i = 0; int32_t i = 0;
for (; i < pState->numOfSub; ++i) { for (; i < pState->numOfSub; ++i) {
SRetrieveSupport *trs = (SRetrieveSupport *)calloc(1, sizeof(SRetrieveSupport)); SRetrieveSupport *trs = (SRetrieveSupport *)TDMCALLOC(1, sizeof(SRetrieveSupport));
if (trs == NULL) { if (trs == NULL) {
tscError("%p failed to malloc buffer for SRetrieveSupport, orderOfSub:%d, reason:%s", pSql, i, strerror(errno)); tscError("%p failed to malloc buffer for SRetrieveSupport, orderOfSub:%d, reason:%s", pSql, i, strerror(errno));
break; break;
...@@ -1732,7 +1732,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { ...@@ -1732,7 +1732,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
trs->pExtMemBuffer = pMemoryBuf; trs->pExtMemBuffer = pMemoryBuf;
trs->pOrderDescriptor = pDesc; trs->pOrderDescriptor = pDesc;
trs->localBuffer = (tFilePage *)calloc(1, nBufferSize + sizeof(tFilePage)); trs->localBuffer = (tFilePage *)TDMCALLOC(1, nBufferSize + sizeof(tFilePage));
if (trs->localBuffer == NULL) { if (trs->localBuffer == NULL) {
tscError("%p failed to malloc buffer for local buffer, orderOfSub:%d, reason:%s", pSql, i, strerror(errno)); tscError("%p failed to malloc buffer for local buffer, orderOfSub:%d, reason:%s", pSql, i, strerror(errno));
TDMFREE(trs); TDMFREE(trs);
...@@ -2346,7 +2346,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { ...@@ -2346,7 +2346,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
if (pSql->pSubs != NULL) { if (pSql->pSubs != NULL) {
for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
SSqlObj* pSub = pSql->pSubs[i]; SSqlObj* pSub = pSql->pSubs[i];
SInsertSupporter* pSup = calloc(1, sizeof(SInsertSupporter)); SInsertSupporter* pSup = TDMCALLOC(1, sizeof(SInsertSupporter));
pSup->index = i; pSup->index = i;
pSup->pSql = pSql; pSup->pSql = pSql;
...@@ -2369,7 +2369,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { ...@@ -2369,7 +2369,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
int32_t numOfSub = 0; int32_t numOfSub = 0;
pSql->subState.numOfRemain = pSql->subState.numOfSub; pSql->subState.numOfRemain = pSql->subState.numOfSub;
pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES); pSql->pSubs = TDMCALLOC(pSql->subState.numOfSub, POINTER_BYTES);
if (pSql->pSubs == NULL) { if (pSql->pSubs == NULL) {
goto _error; goto _error;
} }
...@@ -2377,7 +2377,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { ...@@ -2377,7 +2377,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
tscDebug("%p submit data to %d vnode(s)", pSql, pSql->subState.numOfSub); tscDebug("%p submit data to %d vnode(s)", pSql, pSql->subState.numOfSub);
while(numOfSub < pSql->subState.numOfSub) { while(numOfSub < pSql->subState.numOfSub) {
SInsertSupporter* pSupporter = calloc(1, sizeof(SInsertSupporter)); SInsertSupporter* pSupporter = TDMCALLOC(1, sizeof(SInsertSupporter));
if (pSupporter == NULL) { if (pSupporter == NULL) {
goto _error; goto _error;
} }
...@@ -2467,7 +2467,7 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) { ...@@ -2467,7 +2467,7 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) {
int32_t rowSize = tscGetResRowLength(pQueryInfo->exprList); int32_t rowSize = tscGetResRowLength(pQueryInfo->exprList);
assert(numOfRes * rowSize > 0); assert(numOfRes * rowSize > 0);
char* tmp = realloc(pRes->pRsp, numOfRes * rowSize + sizeof(tFilePage)); char* tmp = TDMREALLOC(pRes->pRsp, numOfRes * rowSize + sizeof(tFilePage));
if (tmp == NULL) { if (tmp == NULL) {
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
return; return;
...@@ -2532,10 +2532,10 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) { ...@@ -2532,10 +2532,10 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex);
pRes->numOfCols = (int16_t) tscSqlExprNumOfExprs(pQueryInfo); pRes->numOfCols = (int16_t) tscSqlExprNumOfExprs(pQueryInfo);
pRes->tsrow = calloc(pRes->numOfCols, POINTER_BYTES); pRes->tsrow = TDMCALLOC(pRes->numOfCols, POINTER_BYTES);
pRes->urow = calloc(pRes->numOfCols, POINTER_BYTES); pRes->urow = TDMCALLOC(pRes->numOfCols, POINTER_BYTES);
pRes->buffer = calloc(pRes->numOfCols, POINTER_BYTES); pRes->buffer = TDMCALLOC(pRes->numOfCols, POINTER_BYTES);
pRes->length = calloc(pRes->numOfCols, sizeof(int32_t)); pRes->length = TDMCALLOC(pRes->numOfCols, sizeof(int32_t));
if (pRes->tsrow == NULL || pRes->buffer == NULL || pRes->length == NULL) { if (pRes->tsrow == NULL || pRes->buffer == NULL || pRes->length == NULL) {
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -2561,7 +2561,7 @@ static UNUSED_FUNC void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TA ...@@ -2561,7 +2561,7 @@ static UNUSED_FUNC void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TA
if (pRes->tsrow[columnIndex] != NULL && pField->type == TSDB_DATA_TYPE_NCHAR) { if (pRes->tsrow[columnIndex] != NULL && pField->type == TSDB_DATA_TYPE_NCHAR) {
// convert unicode to native code in a temporary buffer extra one byte for terminated symbol // convert unicode to native code in a temporary buffer extra one byte for terminated symbol
if (pRes->buffer[columnIndex] == NULL) { if (pRes->buffer[columnIndex] == NULL) {
pRes->buffer[columnIndex] = malloc(pField->bytes + TSDB_NCHAR_SIZE); pRes->buffer[columnIndex] = TDMALLOC(pField->bytes + TSDB_NCHAR_SIZE);
} }
/* string terminated char for binary data*/ /* string terminated char for binary data*/
......
...@@ -265,10 +265,10 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) { ...@@ -265,10 +265,10 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
if (pRes->tsrow == NULL) { if (pRes->tsrow == NULL) {
pRes->numOfCols = pQueryInfo->fieldsInfo.numOfOutput; pRes->numOfCols = pQueryInfo->fieldsInfo.numOfOutput;
pRes->tsrow = calloc(pRes->numOfCols, POINTER_BYTES); pRes->tsrow = TDMCALLOC(pRes->numOfCols, POINTER_BYTES);
pRes->urow = calloc(pRes->numOfCols, POINTER_BYTES); pRes->urow = TDMCALLOC(pRes->numOfCols, POINTER_BYTES);
pRes->length = calloc(pRes->numOfCols, sizeof(int32_t)); pRes->length = TDMCALLOC(pRes->numOfCols, sizeof(int32_t));
pRes->buffer = calloc(pRes->numOfCols, POINTER_BYTES); pRes->buffer = TDMCALLOC(pRes->numOfCols, POINTER_BYTES);
// not enough memory // not enough memory
if (pRes->tsrow == NULL || pRes->urow == NULL || pRes->length == NULL || (pRes->buffer == NULL && pRes->numOfCols > 0)) { if (pRes->tsrow == NULL || pRes->urow == NULL || pRes->length == NULL || (pRes->buffer == NULL && pRes->numOfCols > 0)) {
...@@ -322,7 +322,7 @@ void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo) { ...@@ -322,7 +322,7 @@ void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
} else if (pInfo->field.type == TSDB_DATA_TYPE_NCHAR) { } else if (pInfo->field.type == TSDB_DATA_TYPE_NCHAR) {
// convert unicode to native code in a temporary buffer extra one byte for terminated symbol // convert unicode to native code in a temporary buffer extra one byte for terminated symbol
pRes->buffer[i] = realloc(pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows); pRes->buffer[i] = TDMREALLOC(pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows);
// string terminated char for binary data // string terminated char for binary data
memset(pRes->buffer[i], 0, pInfo->field.bytes * pRes->numOfRows); memset(pRes->buffer[i], 0, pInfo->field.bytes * pRes->numOfRows);
...@@ -531,7 +531,7 @@ SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint ...@@ -531,7 +531,7 @@ SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint
uint32_t needed = pDataBlock->numOfParams + 1; uint32_t needed = pDataBlock->numOfParams + 1;
if (needed > pDataBlock->numOfAllocedParams) { if (needed > pDataBlock->numOfAllocedParams) {
needed *= 2; needed *= 2;
void* tmp = realloc(pDataBlock->params, needed * sizeof(SParamInfo)); void* tmp = TDMREALLOC(pDataBlock->params, needed * sizeof(SParamInfo));
if (tmp == NULL) { if (tmp == NULL) {
return NULL; return NULL;
} }
...@@ -636,7 +636,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) { ...@@ -636,7 +636,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
*/ */
int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, const char* name, int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, const char* name,
STableMeta* pTableMeta, STableDataBlocks** dataBlocks) { STableMeta* pTableMeta, STableDataBlocks** dataBlocks) {
STableDataBlocks* dataBuf = (STableDataBlocks*)calloc(1, sizeof(STableDataBlocks)); STableDataBlocks* dataBuf = (STableDataBlocks*)TDMCALLOC(1, sizeof(STableDataBlocks));
if (dataBuf == NULL) { if (dataBuf == NULL) {
tscError("failed to allocated memory, reason:%s", strerror(errno)); tscError("failed to allocated memory, reason:%s", strerror(errno));
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -648,7 +648,7 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff ...@@ -648,7 +648,7 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
dataBuf->nAllocSize = dataBuf->headerSize*2; dataBuf->nAllocSize = dataBuf->headerSize*2;
} }
dataBuf->pData = calloc(1, dataBuf->nAllocSize); dataBuf->pData = TDMCALLOC(1, dataBuf->nAllocSize);
if (dataBuf->pData == NULL) { if (dataBuf->pData == NULL) {
tscError("failed to allocated memory, reason:%s", strerror(errno)); tscError("failed to allocated memory, reason:%s", strerror(errno));
TDMFREE(dataBuf); TDMFREE(dataBuf);
...@@ -773,7 +773,7 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) { ...@@ -773,7 +773,7 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) {
static void extractTableNameList(SSqlCmd* pCmd) { static void extractTableNameList(SSqlCmd* pCmd) {
pCmd->numOfTables = (int32_t) taosHashGetSize(pCmd->pTableBlockHashList); pCmd->numOfTables = (int32_t) taosHashGetSize(pCmd->pTableBlockHashList);
pCmd->pTableNameList = calloc(pCmd->numOfTables, POINTER_BYTES); pCmd->pTableNameList = TDMCALLOC(pCmd->numOfTables, POINTER_BYTES);
STableDataBlocks **p1 = taosHashIterate(pCmd->pTableBlockHashList, NULL); STableDataBlocks **p1 = taosHashIterate(pCmd->pTableBlockHashList, NULL);
int32_t i = 0; int32_t i = 0;
...@@ -818,7 +818,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql) { ...@@ -818,7 +818,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql) {
dataBuf->nAllocSize = (uint32_t)(dataBuf->nAllocSize * 1.5); dataBuf->nAllocSize = (uint32_t)(dataBuf->nAllocSize * 1.5);
} }
char* tmp = realloc(dataBuf->pData, dataBuf->nAllocSize); char* tmp = TDMREALLOC(dataBuf->pData, dataBuf->nAllocSize);
if (tmp != NULL) { if (tmp != NULL) {
dataBuf->pData = tmp; dataBuf->pData = tmp;
memset(dataBuf->pData + dataBuf->size, 0, dataBuf->nAllocSize - dataBuf->size); memset(dataBuf->pData + dataBuf->size, 0, dataBuf->nAllocSize - dataBuf->size);
...@@ -912,12 +912,12 @@ int tscAllocPayload(SSqlCmd* pCmd, int size) { ...@@ -912,12 +912,12 @@ int tscAllocPayload(SSqlCmd* pCmd, int size) {
if (pCmd->payload == NULL) { if (pCmd->payload == NULL) {
assert(pCmd->allocSize == 0); assert(pCmd->allocSize == 0);
pCmd->payload = (char*)calloc(1, size); pCmd->payload = (char*)TDMCALLOC(1, size);
if (pCmd->payload == NULL) return TSDB_CODE_TSC_OUT_OF_MEMORY; if (pCmd->payload == NULL) return TSDB_CODE_TSC_OUT_OF_MEMORY;
pCmd->allocSize = size; pCmd->allocSize = size;
} else { } else {
if (pCmd->allocSize < (uint32_t)size) { if (pCmd->allocSize < (uint32_t)size) {
char* b = realloc(pCmd->payload, size); char* b = TDMREALLOC(pCmd->payload, size);
if (b == NULL) return TSDB_CODE_TSC_OUT_OF_MEMORY; if (b == NULL) return TSDB_CODE_TSC_OUT_OF_MEMORY;
pCmd->payload = b; pCmd->payload = b;
pCmd->allocSize = size; pCmd->allocSize = size;
...@@ -1061,7 +1061,7 @@ static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SCol ...@@ -1061,7 +1061,7 @@ static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SCol
int16_t size, int16_t resColId, int16_t interSize, int32_t colType) { int16_t size, int16_t resColId, int16_t interSize, int32_t colType) {
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex);
SSqlExpr* pExpr = calloc(1, sizeof(SSqlExpr)); SSqlExpr* pExpr = TDMCALLOC(1, sizeof(SSqlExpr));
if (pExpr == NULL) { if (pExpr == NULL) {
return NULL; return NULL;
} }
...@@ -1196,7 +1196,7 @@ int32_t tscSqlExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepco ...@@ -1196,7 +1196,7 @@ int32_t tscSqlExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepco
if (pExpr->uid == uid) { if (pExpr->uid == uid) {
if (deepcopy) { if (deepcopy) {
SSqlExpr* p1 = calloc(1, sizeof(SSqlExpr)); SSqlExpr* p1 = TDMCALLOC(1, sizeof(SSqlExpr));
if (p1 == NULL) { if (p1 == NULL) {
return -1; return -1;
} }
...@@ -1240,7 +1240,7 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) { ...@@ -1240,7 +1240,7 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
} }
if (i >= numOfCols || numOfCols == 0) { if (i >= numOfCols || numOfCols == 0) {
SColumn* b = calloc(1, sizeof(SColumn)); SColumn* b = TDMCALLOC(1, sizeof(SColumn));
if (b == NULL) { if (b == NULL) {
return NULL; return NULL;
} }
...@@ -1251,7 +1251,7 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) { ...@@ -1251,7 +1251,7 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
SColumn* pCol = taosArrayGetP(pColumnList, i); SColumn* pCol = taosArrayGetP(pColumnList, i);
if (i < numOfCols && (pCol->colIndex.columnIndex > col || pCol->colIndex.tableIndex != pColIndex->tableIndex)) { if (i < numOfCols && (pCol->colIndex.columnIndex > col || pCol->colIndex.tableIndex != pColIndex->tableIndex)) {
SColumn* b = calloc(1, sizeof(SColumn)); SColumn* b = TDMCALLOC(1, sizeof(SColumn));
if (b == NULL) { if (b == NULL) {
return NULL; return NULL;
} }
...@@ -1277,7 +1277,7 @@ static void destroyFilterInfo(SColumnFilterInfo* pFilterInfo, int32_t numOfFilte ...@@ -1277,7 +1277,7 @@ static void destroyFilterInfo(SColumnFilterInfo* pFilterInfo, int32_t numOfFilte
SColumn* tscColumnClone(const SColumn* src) { SColumn* tscColumnClone(const SColumn* src) {
assert(src != NULL); assert(src != NULL);
SColumn* dst = calloc(1, sizeof(SColumn)); SColumn* dst = TDMCALLOC(1, sizeof(SColumn));
if (dst == NULL) { if (dst == NULL) {
return NULL; return NULL;
} }
...@@ -1537,7 +1537,7 @@ int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) { ...@@ -1537,7 +1537,7 @@ int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) {
if (pCond->len > 0) { if (pCond->len > 0) {
assert(pCond->cond != NULL); assert(pCond->cond != NULL);
c.cond = malloc(c.len); c.cond = TDMALLOC(c.len);
if (c.cond == NULL) { if (c.cond == NULL) {
return -1; return -1;
} }
...@@ -1699,14 +1699,14 @@ int32_t tscAddSubqueryInfo(SSqlCmd* pCmd) { ...@@ -1699,14 +1699,14 @@ int32_t tscAddSubqueryInfo(SSqlCmd* pCmd) {
// todo refactor: remove this structure // todo refactor: remove this structure
size_t s = pCmd->numOfClause + 1; size_t s = pCmd->numOfClause + 1;
char* tmp = realloc(pCmd->pQueryInfo, s * POINTER_BYTES); char* tmp = TDMREALLOC(pCmd->pQueryInfo, s * POINTER_BYTES);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
pCmd->pQueryInfo = (SQueryInfo**)tmp; pCmd->pQueryInfo = (SQueryInfo**)tmp;
SQueryInfo* pQueryInfo = calloc(1, sizeof(SQueryInfo)); SQueryInfo* pQueryInfo = TDMCALLOC(1, sizeof(SQueryInfo));
if (pQueryInfo == NULL) { if (pQueryInfo == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -1826,14 +1826,14 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo) { ...@@ -1826,14 +1826,14 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo) {
STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta, STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta,
SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables) { SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables) {
void* pAlloc = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES); void* pAlloc = TDMREALLOC(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES);
if (pAlloc == NULL) { if (pAlloc == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL; return NULL;
} }
pQueryInfo->pTableMetaInfo = pAlloc; pQueryInfo->pTableMetaInfo = pAlloc;
STableMetaInfo* pTableMetaInfo = calloc(1, sizeof(STableMetaInfo)); STableMetaInfo* pTableMetaInfo = TDMCALLOC(1, sizeof(STableMetaInfo));
if (pTableMetaInfo == NULL) { if (pTableMetaInfo == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL; return NULL;
...@@ -1902,7 +1902,7 @@ void registerSqlObj(SSqlObj* pSql) { ...@@ -1902,7 +1902,7 @@ void registerSqlObj(SSqlObj* pSql) {
} }
SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cmd) { SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cmd) {
SSqlObj* pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj)); SSqlObj* pNew = (SSqlObj*)TDMCALLOC(1, sizeof(SSqlObj));
if (pNew == NULL) { if (pNew == NULL) {
tscError("%p new subquery failed, tableIndex:%d", pSql, 0); tscError("%p new subquery failed, tableIndex:%d", pSql, 0);
return NULL; return NULL;
...@@ -1989,7 +1989,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pNewQueryInfo, int64_t ui ...@@ -1989,7 +1989,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pNewQueryInfo, int64_t ui
SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void* param, int32_t cmd, SSqlObj* pPrevSql) { SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void* param, int32_t cmd, SSqlObj* pPrevSql) {
SSqlCmd* pCmd = &pSql->cmd; SSqlCmd* pCmd = &pSql->cmd;
SSqlObj* pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj)); SSqlObj* pNew = (SSqlObj*)TDMCALLOC(1, sizeof(SSqlObj));
if (pNew == NULL) { if (pNew == NULL) {
tscError("%p new subquery failed, tableIndex:%d", pSql, tableIndex); tscError("%p new subquery failed, tableIndex:%d", pSql, tableIndex);
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
...@@ -2058,7 +2058,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void ...@@ -2058,7 +2058,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
} }
if (pQueryInfo->fillType != TSDB_FILL_NONE) { if (pQueryInfo->fillType != TSDB_FILL_NONE) {
pNewQueryInfo->fillVal = malloc(pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t)); pNewQueryInfo->fillVal = TDMALLOC(pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t));
if (pNewQueryInfo->fillVal == NULL) { if (pNewQueryInfo->fillVal == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
goto _error; goto _error;
...@@ -2433,7 +2433,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) { ...@@ -2433,7 +2433,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) {
} }
void* malloc_throw(size_t size) { void* malloc_throw(size_t size) {
void* p = malloc(size); void* p = TDMALLOC(size);
if (p == NULL) { if (p == NULL) {
THROW(TSDB_CODE_TSC_OUT_OF_MEMORY); THROW(TSDB_CODE_TSC_OUT_OF_MEMORY);
} }
...@@ -2441,7 +2441,7 @@ void* malloc_throw(size_t size) { ...@@ -2441,7 +2441,7 @@ void* malloc_throw(size_t size) {
} }
void* calloc_throw(size_t nmemb, size_t size) { void* calloc_throw(size_t nmemb, size_t size) {
void* p = calloc(nmemb, size); void* p = TDMCALLOC(nmemb, size);
if (p == NULL) { if (p == NULL) {
THROW(TSDB_CODE_TSC_OUT_OF_MEMORY); THROW(TSDB_CODE_TSC_OUT_OF_MEMORY);
} }
...@@ -2513,7 +2513,7 @@ SVgroupsInfo* tscVgroupInfoClone(SVgroupsInfo *vgroupList) { ...@@ -2513,7 +2513,7 @@ SVgroupsInfo* tscVgroupInfoClone(SVgroupsInfo *vgroupList) {
} }
size_t size = sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupList->numOfVgroups; size_t size = sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupList->numOfVgroups;
SVgroupsInfo* pNew = calloc(1, size); SVgroupsInfo* pNew = TDMCALLOC(1, size);
if (pNew == NULL) { if (pNew == NULL) {
return NULL; return NULL;
} }
...@@ -2591,7 +2591,7 @@ int32_t copyTagData(STagData* dst, const STagData* src) { ...@@ -2591,7 +2591,7 @@ int32_t copyTagData(STagData* dst, const STagData* src) {
tstrncpy(dst->name, src->name, tListLen(dst->name)); tstrncpy(dst->name, src->name, tListLen(dst->name));
if (dst->dataLen > 0) { if (dst->dataLen > 0) {
dst->data = malloc(dst->dataLen); dst->data = TDMALLOC(dst->dataLen);
if (dst->data == NULL) { if (dst->data == NULL) {
return -1; return -1;
} }
...@@ -2606,7 +2606,7 @@ STableMeta* createSuperTableMeta(STableMetaMsg* pChild) { ...@@ -2606,7 +2606,7 @@ STableMeta* createSuperTableMeta(STableMetaMsg* pChild) {
assert(pChild != NULL); assert(pChild != NULL);
int32_t total = pChild->numOfColumns + pChild->numOfTags; int32_t total = pChild->numOfColumns + pChild->numOfTags;
STableMeta* pTableMeta = calloc(1, sizeof(STableMeta) + sizeof(SSchema) * total); STableMeta* pTableMeta = TDMCALLOC(1, sizeof(STableMeta) + sizeof(SSchema) * total);
pTableMeta->tableType = TSDB_SUPER_TABLE; pTableMeta->tableType = TSDB_SUPER_TABLE;
pTableMeta->tableInfo.numOfTags = pChild->numOfTags; pTableMeta->tableInfo.numOfTags = pChild->numOfTags;
pTableMeta->tableInfo.numOfColumns = pChild->numOfColumns; pTableMeta->tableInfo.numOfColumns = pChild->numOfColumns;
...@@ -2637,7 +2637,7 @@ uint32_t tscGetTableMetaSize(STableMeta* pTableMeta) { ...@@ -2637,7 +2637,7 @@ uint32_t tscGetTableMetaSize(STableMeta* pTableMeta) {
CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta) { CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta) {
assert(pTableMeta != NULL); assert(pTableMeta != NULL);
CChildTableMeta* cMeta = calloc(1, sizeof(CChildTableMeta)); CChildTableMeta* cMeta = TDMCALLOC(1, sizeof(CChildTableMeta));
cMeta->tableType = TSDB_CHILD_TABLE; cMeta->tableType = TSDB_CHILD_TABLE;
cMeta->vgId = pTableMeta->vgId; cMeta->vgId = pTableMeta->vgId;
cMeta->id = pTableMeta->id; cMeta->id = pTableMeta->id;
...@@ -2650,7 +2650,7 @@ int32_t tscCreateTableMetaFromCChildMeta(STableMeta* pChild, const char* name) { ...@@ -2650,7 +2650,7 @@ int32_t tscCreateTableMetaFromCChildMeta(STableMeta* pChild, const char* name) {
assert(pChild != NULL); assert(pChild != NULL);
uint32_t size = tscGetTableMetaMaxSize(); uint32_t size = tscGetTableMetaMaxSize();
STableMeta* p = calloc(1, size); STableMeta* p = TDMCALLOC(1, size);
taosHashGetClone(tscTableMetaInfo, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, p, -1); taosHashGetClone(tscTableMetaInfo, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, p, -1);
if (p->id.uid > 0) { // tableMeta exists, build child table meta and return if (p->id.uid > 0) { // tableMeta exists, build child table meta and return
...@@ -2679,7 +2679,7 @@ uint32_t tscGetTableMetaMaxSize() { ...@@ -2679,7 +2679,7 @@ uint32_t tscGetTableMetaMaxSize() {
STableMeta* tscTableMetaClone(STableMeta* pTableMeta) { STableMeta* tscTableMetaClone(STableMeta* pTableMeta) {
assert(pTableMeta != NULL); assert(pTableMeta != NULL);
uint32_t size = tscGetTableMetaSize(pTableMeta); uint32_t size = tscGetTableMetaSize(pTableMeta);
STableMeta* p = calloc(1, size); STableMeta* p = TDMCALLOC(1, size);
memcpy(p, pTableMeta, size); memcpy(p, pTableMeta, size);
return p; return p;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册