提交 c5e02db6 编写于 作者: S shenglian zhou

fix memory leak

上级 660241e3
...@@ -1781,12 +1781,28 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData) { ...@@ -1781,12 +1781,28 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData) {
//========================================================================= //=========================================================================
void destroySmlDataPoint(TAOS_SML_DATA_POINT* point) {
for (int i=0; i<point->tagNum; ++i) {
free((point->tags+i)->key);
free((point->tags+i)->value);
}
free(point->tags);
for (int i=0; i<point->fieldNum; ++i) {
free((point->fields+i)->key);
free((point->fields+i)->value);
}
free(point->fields);
free(point->stableName);
free(point->childTableName);
}
int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) {
for (int32_t i = 0; i < numLines; ++i) { for (int32_t i = 0; i < numLines; ++i) {
TAOS_SML_DATA_POINT point = {0}; TAOS_SML_DATA_POINT point = {0};
int32_t code = tscParseLine(lines[i], &point); int32_t code = tscParseLine(lines[i], &point);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
tscError("data point line parse failed. line %d : %s", i, lines[i]); tscError("data point line parse failed. line %d : %s", i, lines[i]);
destroySmlDataPoint(&point);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
} else { } else {
tscDebug("data point line parse success. line %d", i); tscDebug("data point line parse success. line %d", i);
...@@ -1797,22 +1813,6 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile ...@@ -1797,22 +1813,6 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile
return 0; return 0;
} }
void destroySmlDataPoint(TAOS_SML_DATA_POINT* point) {
for (int i=0; i<point->tagNum; ++i) {
free((point->tags+i)->key);
free((point->tags+i)->value);
}
free(point->tags);
for (int i=0; i<point->fieldNum; ++i) {
free((point->fields+i)->key);
free((point->fields+i)->value);
}
free(point->fields);
free(point->stableName);
free(point->childTableName);
}
int taos_insert_lines(TAOS* taos, char* lines[], int numLines) { int taos_insert_lines(TAOS* taos, char* lines[], int numLines) {
int32_t code = 0; int32_t code = 0;
SArray* lpPoints = taosArrayInit(numLines, sizeof(TAOS_SML_DATA_POINT)); SArray* lpPoints = taosArrayInit(numLines, sizeof(TAOS_SML_DATA_POINT));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册