From 614462b8785f33535e181fe239d632b9b146f273 Mon Sep 17 00:00:00 2001 From: kailixu Date: Sat, 3 Dec 2022 21:47:08 +0800 Subject: [PATCH] refact: free func update when build submit req --- include/common/tmsg.h | 3 ++- include/os/osMemory.h | 1 + source/common/src/tmsg.c | 4 ++-- source/dnode/vnode/src/tq/tqSink.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index eaf34c0a3d..c7f3caafb5 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -3264,7 +3264,8 @@ void tDestroySSubmitRsp2(SSubmitRsp2* pRsp, int32_t flag); #define TSDB_MSG_FLG_ENCODE 0x1 #define TSDB_MSG_FLG_DECODE 0x2 -int32_t tBuildSubmitReq(int32_t vgId, SSubmitReq2* pReq, void** pData, uint32_t* pLen, __tmalloc_fn_t fp); +int32_t tBuildSubmitReq(int32_t vgId, SSubmitReq2* pReq, void** pData, uint32_t* pLen, __tmalloc_fn_t fp, + __tfree_fn_t ff); #pragma pack(pop) diff --git a/include/os/osMemory.h b/include/os/osMemory.h index 4f06c4f2ce..a13b8f3014 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -48,6 +48,7 @@ void *taosMemoryMallocAlign(uint32_t alignment, int64_t size); } while (0) typedef void *(*__tmalloc_fn_t)(int64_t); +typedef void (*__tfree_fn_t)(void *); #ifdef __cplusplus } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 2548422ed8..47738e3436 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -7001,7 +7001,7 @@ void tDestroySSubmitRsp2(SSubmitRsp2 *pRsp, int32_t flag) { } } -int32_t tBuildSubmitReq(int32_t vgId, SSubmitReq2 *pReq, void **pData, uint32_t *pLen, __tmalloc_fn_t fp) { +int32_t tBuildSubmitReq(int32_t vgId, SSubmitReq2 *pReq, void **pData, uint32_t *pLen, __tmalloc_fn_t fp, __tfree_fn_t ff) { int32_t code = TSDB_CODE_SUCCESS; uint32_t len = 0; void *pBuf = NULL; @@ -7024,7 +7024,7 @@ int32_t tBuildSubmitReq(int32_t vgId, SSubmitReq2 *pReq, void **pData, uint32_t *pData = pBuf; *pLen = len; } else { - taosMemoryFree(pBuf); + (*ff)(pBuf); } return code; } \ No newline at end of file diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index d2a26dc3a8..49c4973342 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -463,7 +463,7 @@ int32_t tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* p taosArrayPush(pReq->aSubmitTbData, pTbData); } - terrno = tBuildSubmitReq(TD_VID(pVnode), pReq, ppData, pLen, rpcMallocCont); + terrno = tBuildSubmitReq(TD_VID(pVnode), pReq, ppData, pLen, rpcMallocCont, rpcFreeCont); _end: taosArrayDestroy(tagArray); -- GitLab