提交 d3cc956b 编写于 作者: H Hongze Cheng

fix: memory leak

上级 f4f08b24
...@@ -2073,8 +2073,9 @@ typedef struct SVCreateTbReq { ...@@ -2073,8 +2073,9 @@ typedef struct SVCreateTbReq {
}; };
} SVCreateTbReq; } SVCreateTbReq;
int tEncodeSVCreateTbReq(SEncoder* pCoder, const SVCreateTbReq* pReq); int tEncodeSVCreateTbReq(SEncoder* pCoder, const SVCreateTbReq* pReq);
int tDecodeSVCreateTbReq(SDecoder* pCoder, SVCreateTbReq* pReq); int tDecodeSVCreateTbReq(SDecoder* pCoder, SVCreateTbReq* pReq);
void tDestroySVCreateTbReq(SVCreateTbReq* pReq, int32_t flags);
static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) { static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) {
if (NULL == req) { if (NULL == req) {
......
...@@ -992,7 +992,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { ...@@ -992,7 +992,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
if (tEncodeI32(&encoder, vlen) < 0) return -1; if (tEncodeI32(&encoder, vlen) < 0) return -1;
for (int32_t i = 0; i < vlen; ++i) { for (int32_t i = 0; i < vlen; ++i) {
SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i); SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i);
int64_t reserved = 0; int64_t reserved = 0;
if (tEncodeI32(&encoder, pload->vgId) < 0) return -1; if (tEncodeI32(&encoder, pload->vgId) < 0) return -1;
if (tEncodeI8(&encoder, pload->syncState) < 0) return -1; if (tEncodeI8(&encoder, pload->syncState) < 0) return -1;
if (tEncodeI8(&encoder, pload->syncRestore) < 0) return -1; if (tEncodeI8(&encoder, pload->syncRestore) < 0) return -1;
...@@ -5696,6 +5696,25 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { ...@@ -5696,6 +5696,25 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
return 0; return 0;
} }
void tDestroySVCreateTbReq(SVCreateTbReq *pReq, int32_t flags) {
if (pReq == NULL) return;
if (flags & TSDB_MSG_FLG_ENCODE) {
// TODO
} else if (flags & TSDB_MSG_FLG_DECODE) {
if (pReq->comment) {
pReq->comment = NULL;
taosMemoryFree(pReq->comment);
}
if (pReq->type == TSDB_CHILD_TABLE) {
if (pReq->ctb.tagName) taosArrayDestroy(pReq->ctb.tagName);
} else if (pReq->type == TSDB_NORMAL_TABLE) {
if (pReq->ntb.schemaRow.pSchema) taosMemoryFree(pReq->ntb.schemaRow.pSchema);
}
}
}
int tEncodeSVCreateTbBatchReq(SEncoder *pCoder, const SVCreateTbBatchReq *pReq) { int tEncodeSVCreateTbBatchReq(SEncoder *pCoder, const SVCreateTbBatchReq *pReq) {
int32_t nReq = taosArrayGetSize(pReq->pArray); int32_t nReq = taosArrayGetSize(pReq->pArray);
...@@ -6870,7 +6889,7 @@ void tDestroySSubmitTbData(SSubmitTbData *pTbData, int32_t flag) { ...@@ -6870,7 +6889,7 @@ void tDestroySSubmitTbData(SSubmitTbData *pTbData, int32_t flag) {
if (NULL == pTbData) { if (NULL == pTbData) {
return; return;
} }
if (flag == TSDB_MSG_FLG_ENCODE) { if (flag == TSDB_MSG_FLG_ENCODE) {
if (pTbData->pCreateTbReq) { if (pTbData->pCreateTbReq) {
tdDestroySVCreateTbReq(pTbData->pCreateTbReq); tdDestroySVCreateTbReq(pTbData->pCreateTbReq);
...@@ -6896,6 +6915,7 @@ void tDestroySSubmitTbData(SSubmitTbData *pTbData, int32_t flag) { ...@@ -6896,6 +6915,7 @@ void tDestroySSubmitTbData(SSubmitTbData *pTbData, int32_t flag) {
} }
} else if (flag == TSDB_MSG_FLG_DECODE) { } else if (flag == TSDB_MSG_FLG_DECODE) {
if (pTbData->pCreateTbReq) { if (pTbData->pCreateTbReq) {
tDestroySVCreateTbReq(pTbData->pCreateTbReq, TSDB_MSG_FLG_DECODE);
taosMemoryFree(pTbData->pCreateTbReq); taosMemoryFree(pTbData->pCreateTbReq);
} }
...@@ -6984,7 +7004,7 @@ void tDestroySSubmitRsp2(SSubmitRsp2 *pRsp, int32_t flag) { ...@@ -6984,7 +7004,7 @@ void tDestroySSubmitRsp2(SSubmitRsp2 *pRsp, int32_t flag) {
if (NULL == pRsp) { if (NULL == pRsp) {
return; return;
} }
if (flag & TSDB_MSG_FLG_ENCODE) { if (flag & TSDB_MSG_FLG_ENCODE) {
if (pRsp->aCreateTbRsp) { if (pRsp->aCreateTbRsp) {
int32_t nCreateTbRsp = TARRAY_SIZE(pRsp->aCreateTbRsp); int32_t nCreateTbRsp = TARRAY_SIZE(pRsp->aCreateTbRsp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册