Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9e663ecd
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9e663ecd
编写于
11月 10, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
11月 10, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4171 from taosdata/feature/wal
TD-1793
上级
2554a1b5
42693517
变更
79
隐藏空白更改
内联
并排
Showing
79 changed file
with
465 addition
and
573 deletion
+465
-573
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+1
-1
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+31
-31
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+5
-5
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+2
-2
src/client/src/tscServer.c
src/client/src/tscServer.c
+4
-4
src/client/src/tscSql.c
src/client/src/tscSql.c
+3
-3
src/client/src/tscStream.c
src/client/src/tscStream.c
+2
-2
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+14
-14
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+37
-37
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+2
-2
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+5
-5
src/common/src/tvariant.c
src/common/src/tvariant.c
+1
-1
src/cq/src/cqMain.c
src/cq/src/cqMain.c
+1
-1
src/dnode/src/dnodeMPeer.c
src/dnode/src/dnodeMPeer.c
+1
-1
src/dnode/src/dnodeMWrite.c
src/dnode/src/dnodeMWrite.c
+1
-1
src/inc/mnode.h
src/inc/mnode.h
+1
-0
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/kit/shell/inc/shell.h
src/kit/shell/inc/shell.h
+1
-1
src/kit/shell/src/shellDarwin.c
src/kit/shell/src/shellDarwin.c
+2
-2
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+8
-7
src/kit/shell/src/shellLinux.c
src/kit/shell/src/shellLinux.c
+3
-3
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+1
-1
src/mnode/src/mnodeAcct.c
src/mnode/src/mnodeAcct.c
+1
-1
src/mnode/src/mnodeCluster.c
src/mnode/src/mnodeCluster.c
+1
-1
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+3
-3
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+2
-2
src/mnode/src/mnodeInt.c
src/mnode/src/mnodeInt.c
+1
-0
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+3
-3
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+2
-2
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+1
-1
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+1
-1
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+22
-11
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+2
-2
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+1
-1
src/os/inc/os.h
src/os/inc/os.h
+0
-1
src/os/inc/osAlloc.h
src/os/inc/osAlloc.h
+0
-43
src/os/inc/osMemory.h
src/os/inc/osMemory.h
+31
-30
src/os/src/detail/osAlloc.c
src/os/src/detail/osAlloc.c
+0
-79
src/os/src/detail/osMemory.c
src/os/src/detail/osMemory.c
+62
-62
src/os/src/detail/osSysinfo.c
src/os/src/detail/osSysinfo.c
+7
-7
src/plugins/http/src/httpContext.c
src/plugins/http/src/httpContext.c
+1
-1
src/plugins/http/src/httpSystem.c
src/plugins/http/src/httpSystem.c
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+49
-49
src/query/src/qExtbuffer.c
src/query/src/qExtbuffer.c
+8
-8
src/query/src/qFill.c
src/query/src/qFill.c
+8
-8
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+4
-4
src/query/src/qPercentile.c
src/query/src/qPercentile.c
+3
-3
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+6
-6
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+4
-4
src/query/src/qUtil.c
src/query/src/qUtil.c
+3
-3
src/rpc/src/rpcCache.c
src/rpc/src/rpcCache.c
+3
-3
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+2
-2
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+5
-5
src/rpc/src/rpcUdp.c
src/rpc/src/rpcUdp.c
+2
-2
src/sync/inc/taosTcpPool.h
src/sync/inc/taosTcpPool.h
+11
-11
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+5
-5
src/sync/src/syncRestore.c
src/sync/src/syncRestore.c
+2
-2
src/sync/src/taosTcpPool.c
src/sync/src/taosTcpPool.c
+1
-1
src/sync/src/tarbitrator.c
src/sync/src/tarbitrator.c
+2
-2
src/tsdb/src/tsdbBuffer.c
src/tsdb/src/tsdbBuffer.c
+1
-1
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+3
-3
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+11
-11
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+4
-4
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+10
-10
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+11
-11
src/tsdb/tests/tsdbTests.cpp
src/tsdb/tests/tsdbTests.cpp
+2
-2
src/util/src/hash.c
src/util/src/hash.c
+2
-2
src/util/src/talgo.c
src/util/src/talgo.c
+1
-1
src/util/src/tcache.c
src/util/src/tcache.c
+2
-2
src/util/src/tconfig.c
src/util/src/tconfig.c
+4
-4
src/util/src/tkvstore.c
src/util/src/tkvstore.c
+5
-5
src/util/src/tlog.c
src/util/src/tlog.c
+3
-3
src/util/src/tmempool.c
src/util/src/tmempool.c
+3
-3
src/util/src/tref.c
src/util/src/tref.c
+2
-2
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+4
-4
src/util/tests/skiplistTest.cpp
src/util/tests/skiplistTest.cpp
+5
-5
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+1
-1
src/wal/src/walMgmt.c
src/wal/src/walMgmt.c
+1
-2
tests/tsim/src/simSystem.c
tests/tsim/src/simSystem.c
+3
-3
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
9e663ecd
...
...
@@ -2117,7 +2117,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
}
}
t
aosTF
ree
(
pData
);
t
f
ree
(
pData
);
}
/*
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
9e663ecd
...
...
@@ -227,7 +227,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
if
(
ds
==
NULL
)
{
tscError
(
"%p failed to create merge structure"
,
pSql
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
t
aosTF
ree
(
pReducer
);
t
f
ree
(
pReducer
);
return
;
}
...
...
@@ -254,7 +254,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
if
(
ds
->
filePage
.
num
==
0
)
{
// no data in this flush, the index does not increase
tscDebug
(
"%p flush data is empty, ignore %d flush record"
,
pSql
,
idx
);
t
aosTF
ree
(
ds
);
t
f
ree
(
ds
);
continue
;
}
...
...
@@ -264,7 +264,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
// no data actually, no need to merge result.
if
(
idx
==
0
)
{
t
aosTF
ree
(
pReducer
);
t
f
ree
(
pReducer
);
return
;
}
...
...
@@ -272,7 +272,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
SCompareParam
*
param
=
malloc
(
sizeof
(
SCompareParam
));
if
(
param
==
NULL
)
{
t
aosTF
ree
(
pReducer
);
t
f
ree
(
pReducer
);
return
;
}
...
...
@@ -286,8 +286,8 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pRes
->
code
=
tLoserTreeCreate
(
&
pReducer
->
pLoserTree
,
pReducer
->
numOfBuffer
,
param
,
treeComparator
);
if
(
pReducer
->
pLoserTree
==
NULL
||
pRes
->
code
!=
0
)
{
t
aosTF
ree
(
param
);
t
aosTF
ree
(
pReducer
);
t
f
ree
(
param
);
t
f
ree
(
pReducer
);
return
;
}
...
...
@@ -330,14 +330,14 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
if
(
pReducer
->
pTempBuffer
==
NULL
||
pReducer
->
discardData
==
NULL
||
pReducer
->
pResultBuf
==
NULL
||
/*pReducer->pBufForInterpo == NULL || */
pReducer
->
pFinalRes
==
NULL
||
pReducer
->
prevRowOfInput
==
NULL
)
{
t
aosTF
ree
(
pReducer
->
pTempBuffer
);
t
aosTF
ree
(
pReducer
->
discardData
);
t
aosTF
ree
(
pReducer
->
pResultBuf
);
t
aosTF
ree
(
pReducer
->
pFinalRes
);
t
aosTF
ree
(
pReducer
->
prevRowOfInput
);
t
aosTF
ree
(
pReducer
->
pLoserTree
);
t
aosTF
ree
(
param
);
t
aosTF
ree
(
pReducer
);
t
f
ree
(
pReducer
->
pTempBuffer
);
t
f
ree
(
pReducer
->
discardData
);
t
f
ree
(
pReducer
->
pResultBuf
);
t
f
ree
(
pReducer
->
pFinalRes
);
t
f
ree
(
pReducer
->
prevRowOfInput
);
t
f
ree
(
pReducer
->
pLoserTree
);
t
f
ree
(
param
);
t
f
ree
(
pReducer
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
;
}
...
...
@@ -495,33 +495,33 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
i
];
tVariantDestroy
(
&
pCtx
->
tag
);
t
aosTF
ree
(
pCtx
->
resultInfo
);
t
f
ree
(
pCtx
->
resultInfo
);
if
(
pCtx
->
tagInfo
.
pTagCtxList
!=
NULL
)
{
t
aosTF
ree
(
pCtx
->
tagInfo
.
pTagCtxList
);
t
f
ree
(
pCtx
->
tagInfo
.
pTagCtxList
);
}
}
t
aosTF
ree
(
pLocalReducer
->
pCtx
);
t
f
ree
(
pLocalReducer
->
pCtx
);
}
t
aosTF
ree
(
pLocalReducer
->
prevRowOfInput
);
t
f
ree
(
pLocalReducer
->
prevRowOfInput
);
t
aosTF
ree
(
pLocalReducer
->
pTempBuffer
);
t
aosTF
ree
(
pLocalReducer
->
pResultBuf
);
t
f
ree
(
pLocalReducer
->
pTempBuffer
);
t
f
ree
(
pLocalReducer
->
pResultBuf
);
if
(
pLocalReducer
->
pLoserTree
)
{
t
aosTF
ree
(
pLocalReducer
->
pLoserTree
->
param
);
t
aosTF
ree
(
pLocalReducer
->
pLoserTree
);
t
f
ree
(
pLocalReducer
->
pLoserTree
->
param
);
t
f
ree
(
pLocalReducer
->
pLoserTree
);
}
t
aosTF
ree
(
pLocalReducer
->
pFinalRes
);
t
aosTF
ree
(
pLocalReducer
->
discardData
);
t
f
ree
(
pLocalReducer
->
pFinalRes
);
t
f
ree
(
pLocalReducer
->
discardData
);
tscLocalReducerEnvDestroy
(
pLocalReducer
->
pExtMemBuffer
,
pLocalReducer
->
pDesc
,
pLocalReducer
->
resColModel
,
pLocalReducer
->
numOfVnode
);
for
(
int32_t
i
=
0
;
i
<
pLocalReducer
->
numOfBuffer
;
++
i
)
{
t
aosTF
ree
(
pLocalReducer
->
pLocalDataSrc
[
i
]);
t
f
ree
(
pLocalReducer
->
pLocalDataSrc
[
i
]);
}
pLocalReducer
->
numOfBuffer
=
0
;
...
...
@@ -588,7 +588,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
}
*
pOrderDesc
=
tOrderDesCreate
(
orderColIndexList
,
numOfGroupByCols
,
pModel
,
pQueryInfo
->
order
.
order
);
t
aosTF
ree
(
orderColIndexList
);
t
f
ree
(
orderColIndexList
);
if
(
*
pOrderDesc
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
@@ -699,7 +699,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
if
(
createOrderDescriptor
(
pOrderDesc
,
pCmd
,
pModel
)
!=
TSDB_CODE_SUCCESS
)
{
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
t
aosTF
ree
(
pSchema
);
t
f
ree
(
pSchema
);
return
pRes
->
code
;
}
...
...
@@ -736,7 +736,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
}
*
pFinalModel
=
createColumnModel
(
pSchema
,
(
int32_t
)
size
,
capacity
);
t
aosTF
ree
(
pSchema
);
t
f
ree
(
pSchema
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -756,7 +756,7 @@ void tscLocalReducerEnvDestroy(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDe
pMemBuffer
[
i
]
=
destoryExtMemBuffer
(
pMemBuffer
[
i
]);
}
t
aosTF
ree
(
pMemBuffer
);
t
f
ree
(
pMemBuffer
);
}
/**
...
...
@@ -978,10 +978,10 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
pBeforeFillData
->
num
=
0
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
t
aosTF
ree
(
pResPages
[
i
]);
t
f
ree
(
pResPages
[
i
]);
}
t
aosTF
ree
(
pResPages
);
t
f
ree
(
pResPages
);
}
static
void
savePreviousRow
(
SLocalReducer
*
pLocalReducer
,
tFilePage
*
tmpBuffer
)
{
...
...
src/client/src/tscParseInsert.c
浏览文件 @
9e663ecd
...
...
@@ -1406,7 +1406,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
assert
(
taos_errno
(
pSql
)
==
code
);
taos_free_result
(
pSql
);
t
aosTF
ree
(
pSupporter
);
t
f
ree
(
pSupporter
);
fclose
(
fp
);
pParentSql
->
res
.
code
=
code
;
...
...
@@ -1445,7 +1445,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
char
*
tokenBuf
=
calloc
(
1
,
4096
);
while
((
readLen
=
t
aosG
etline
(
&
line
,
&
n
,
fp
))
!=
-
1
)
{
while
((
readLen
=
t
g
etline
(
&
line
,
&
n
,
fp
))
!=
-
1
)
{
if
((
'\r'
==
line
[
readLen
-
1
])
||
(
'\n'
==
line
[
readLen
-
1
]))
{
line
[
--
readLen
]
=
0
;
}
...
...
@@ -1470,7 +1470,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
}
}
t
aosTF
ree
(
tokenBuf
);
t
f
ree
(
tokenBuf
);
free
(
line
);
if
(
count
>
0
)
{
...
...
@@ -1483,7 +1483,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
}
else
{
taos_free_result
(
pSql
);
t
aosTF
ree
(
pSupporter
);
t
f
ree
(
pSupporter
);
fclose
(
fp
);
pParentSql
->
fp
=
pParentSql
->
fetchFp
;
...
...
@@ -1513,7 +1513,7 @@ void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) {
pSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
tscError
(
"%p failed to open file %s to load data from file, code:%s"
,
pSql
,
pCmd
->
payload
,
tstrerror
(
pSql
->
res
.
code
));
t
aosTF
ree
(
pSupporter
)
t
f
ree
(
pSupporter
)
tscQueueAsyncRes
(
pSql
);
return
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
9e663ecd
...
...
@@ -3957,7 +3957,7 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
int32_t
ret
=
setObjFullName
(
idBuf
,
account
,
&
dbToken
,
&
t
,
&
xlen
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
taosStringBuilderDestroy
(
&
sb1
);
t
aosTF
ree
(
segments
);
t
f
ree
(
segments
);
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
return
ret
;
...
...
@@ -3970,7 +3970,7 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
pQueryInfo
->
tagCond
.
tbnameCond
.
cond
=
strdup
(
str
);
taosStringBuilderDestroy
(
&
sb1
);
t
aosTF
ree
(
segments
);
t
f
ree
(
segments
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/client/src/tscServer.c
浏览文件 @
9e663ecd
...
...
@@ -124,7 +124,7 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
pVgroupInfo
->
inUse
=
pEpSet
->
inUse
;
pVgroupInfo
->
numOfEps
=
pEpSet
->
numOfEps
;
for
(
int32_t
i
=
0
;
i
<
pVgroupInfo
->
numOfEps
;
i
++
)
{
t
aosTF
ree
(
pVgroupInfo
->
epAddr
[
i
].
fqdn
);
t
f
ree
(
pVgroupInfo
->
epAddr
[
i
].
fqdn
);
pVgroupInfo
->
epAddr
[
i
].
fqdn
=
strndup
(
pEpSet
->
fqdn
[
i
],
tListLen
(
pEpSet
->
fqdn
[
i
]));
pVgroupInfo
->
epAddr
[
i
].
port
=
pEpSet
->
port
[
i
];
}
...
...
@@ -1549,7 +1549,7 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
memcpy(pInfoMsg->tableIds, tmpData, pCmd->payloadLen);
}
t
aosTF
ree(tmpData);
t
f
ree(tmpData);
pCmd->payloadLen += sizeof(SMgmtHead) + sizeof(SMultiTableInfoMsg);
pCmd->msgType = TSDB_MSG_TYPE_CM_TABLES_META;
...
...
@@ -1956,7 +1956,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
tscFieldInfoUpdateOffset
(
pQueryInfo
);
t
aosTF
ree
(
pTableMeta
);
t
f
ree
(
pTableMeta
);
return
0
;
}
...
...
@@ -1981,7 +1981,7 @@ static void createHBObj(STscObj* pObj) {
pSql
->
cmd
.
command
=
pQueryInfo
->
command
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
&
(
pSql
->
cmd
),
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
t
aosTF
ree
(
pSql
);
t
f
ree
(
pSql
);
return
;
}
...
...
src/client/src/tscSql.c
浏览文件 @
9e663ecd
...
...
@@ -566,7 +566,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
pRes->rspType = 0;
pSql->subState.numOfSub = 0;
t
aosTF
ree(pSql->pSubs);
t
f
ree(pSql->pSubs);
assert(pSql->fp == NULL);
...
...
@@ -894,7 +894,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
if
(
sqlLen
>
tsMaxSQLStringLen
)
{
tscError
(
"%p sql too long"
,
pSql
);
pRes
->
code
=
TSDB_CODE_TSC_INVALID_SQL
;
t
aosTF
ree
(
pSql
);
t
f
ree
(
pSql
);
return
pRes
->
code
;
}
...
...
@@ -903,7 +903,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
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
);
t
aosTF
ree
(
pSql
);
t
f
ree
(
pSql
);
return
pRes
->
code
;
}
...
...
src/client/src/tscStream.c
浏览文件 @
9e663ecd
...
...
@@ -273,7 +273,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
taosCacheRelease
(
tscMetaCache
,
(
void
**
)
&
(
pTableMetaInfo
->
pTableMeta
),
false
);
tscFreeSqlResult
(
pSql
);
t
aosTF
ree
(
pSql
->
pSubs
);
t
f
ree
(
pSql
->
pSubs
);
pSql
->
subState
.
numOfSub
=
0
;
pTableMetaInfo
->
vgroupList
=
tscVgroupInfoClear
(
pTableMetaInfo
->
vgroupList
);
tscSetNextLaunchTimer
(
pStream
,
pSql
);
...
...
@@ -617,6 +617,6 @@ void taos_close_stream(TAOS_STREAM *handle) {
pStream
->
pSql
=
NULL
;
taos_free_result
(
pSql
);
t
aosTF
ree
(
pStream
);
t
f
ree
(
pStream
);
}
}
src/client/src/tscSubquery.c
浏览文件 @
9e663ecd
...
...
@@ -255,7 +255,7 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) {
pSupporter
->
pVgroupTables
=
NULL
;
}
t
aosTF
ree
(
pSupporter
->
pIdTagList
);
t
f
ree
(
pSupporter
->
pIdTagList
);
tscTagCondRelease
(
&
pSupporter
->
tagCond
);
free
(
pSupporter
);
}
...
...
@@ -308,7 +308,7 @@ static void filterVgroupTables(SQueryInfo* pQueryInfo, SArray* pVgroupTables) {
assert
(
taosArrayGetSize
(
pVgroupTables
)
>
0
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_MULTITABLE_QUERY
);
t
aosTF
ree
(
list
);
t
f
ree
(
list
);
}
static
SArray
*
buildVgroupTableByResult
(
SQueryInfo
*
pQueryInfo
,
SArray
*
pVgroupTables
)
{
...
...
@@ -335,7 +335,7 @@ static SArray* buildVgroupTableByResult(SQueryInfo* pQueryInfo, SArray* pVgroupT
taosArrayPush
(
pNew
,
&
info
);
}
t
aosTF
ree
(
list
);
t
f
ree
(
list
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_MULTITABLE_QUERY
);
return
pNew
;
...
...
@@ -1624,8 +1624,8 @@ static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs) {
SRetrieveSupport
*
pSupport
=
pSub
->
param
;
t
aosTF
ree
(
pSupport
->
localBuffer
);
t
aosTF
ree
(
pSupport
);
t
f
ree
(
pSupport
->
localBuffer
);
t
f
ree
(
pSupport
);
taos_free_result
(
pSub
);
}
...
...
@@ -1666,7 +1666,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
if
(
ret
!=
0
)
{
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tscQueueAsyncRes
(
pSql
);
t
aosTF
ree
(
pMemoryBuf
);
t
f
ree
(
pMemoryBuf
);
return
ret
;
}
...
...
@@ -1675,7 +1675,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
tscDebug
(
"%p retrieved query data from %d vnode(s)"
,
pSql
,
pState
->
numOfSub
);
if
(
pSql
->
pSubs
==
NULL
)
{
t
aosTF
ree
(
pSql
->
pSubs
);
t
f
ree
(
pSql
->
pSubs
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tscLocalReducerEnvDestroy
(
pMemoryBuf
,
pDesc
,
pModel
,
pState
->
numOfSub
);
...
...
@@ -1700,7 +1700,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
trs
->
localBuffer
=
(
tFilePage
*
)
calloc
(
1
,
nBufferSize
+
sizeof
(
tFilePage
));
if
(
trs
->
localBuffer
==
NULL
)
{
tscError
(
"%p failed to malloc buffer for local buffer, orderOfSub:%d, reason:%s"
,
pSql
,
i
,
strerror
(
errno
));
t
aosTF
ree
(
trs
);
t
f
ree
(
trs
);
break
;
}
...
...
@@ -1711,8 +1711,8 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
SSqlObj
*
pNew
=
tscCreateSTableSubquery
(
pSql
,
trs
,
NULL
);
if
(
pNew
==
NULL
)
{
tscError
(
"%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s"
,
pSql
,
i
,
strerror
(
errno
));
t
aosTF
ree
(
trs
->
localBuffer
);
t
aosTF
ree
(
trs
);
t
f
ree
(
trs
->
localBuffer
);
t
f
ree
(
trs
);
break
;
}
...
...
@@ -1766,8 +1766,8 @@ static void tscFreeRetrieveSup(SSqlObj *pSql) {
// SSqlObj *pParentSql = trsupport->pParentSql;
// assert(pSql == pParentSql->pSubs[index]);
t
aosTF
ree
(
trsupport
->
localBuffer
);
t
aosTF
ree
(
trsupport
);
t
f
ree
(
trsupport
->
localBuffer
);
t
f
ree
(
trsupport
);
}
static
void
tscRetrieveFromDnodeCallBack
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
...
...
@@ -2167,7 +2167,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
pParentObj
->
res
.
code
=
pSql
->
res
.
code
;
}
t
aosTF
ree
(
pSupporter
);
t
f
ree
(
pSupporter
);
if
(
atomic_sub_fetch_32
(
&
pParentObj
->
subState
.
numOfRemain
,
1
)
>
0
)
{
return
;
...
...
@@ -2442,7 +2442,7 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql, bool finalResult) {
assert
(
pRes
->
row
>=
0
&&
pRes
->
row
<=
pRes
->
numOfRows
);
if
(
pRes
->
row
>=
pRes
->
numOfRows
)
{
// all the results has returned to invoker
t
aosTF
ree
(
pRes
->
tsrow
);
t
f
ree
(
pRes
->
tsrow
);
return
pRes
->
tsrow
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
9e663ecd
...
...
@@ -245,7 +245,7 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
}
pQueryInfo
->
fillType
=
TSDB_FILL_NONE
;
t
aosTF
ree
(
pQueryInfo
->
fillVal
);
t
f
ree
(
pQueryInfo
->
fillVal
);
}
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
)
{
...
...
@@ -259,7 +259,7 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
// not enough memory
if
(
pRes
->
tsrow
==
NULL
||
(
pRes
->
buffer
==
NULL
&&
pRes
->
numOfCols
>
0
))
{
t
aosTF
ree
(
pRes
->
tsrow
);
t
f
ree
(
pRes
->
tsrow
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
pRes
->
code
;
}
...
...
@@ -271,24 +271,24 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
static
void
tscDestroyResPointerInfo
(
SSqlRes
*
pRes
)
{
if
(
pRes
->
buffer
!=
NULL
)
{
// free all buffers containing the multibyte string
for
(
int
i
=
0
;
i
<
pRes
->
numOfCols
;
i
++
)
{
t
aosTF
ree
(
pRes
->
buffer
[
i
]);
t
f
ree
(
pRes
->
buffer
[
i
]);
}
pRes
->
numOfCols
=
0
;
}
t
aosTF
ree
(
pRes
->
pRsp
);
t
f
ree
(
pRes
->
pRsp
);
t
aosTF
ree
(
pRes
->
tsrow
);
t
aosTF
ree
(
pRes
->
length
);
t
aosTF
ree
(
pRes
->
buffer
);
t
f
ree
(
pRes
->
tsrow
);
t
f
ree
(
pRes
->
length
);
t
f
ree
(
pRes
->
buffer
);
t
aosTF
ree
(
pRes
->
pGroupRec
);
t
aosTF
ree
(
pRes
->
pColumnIndex
);
t
f
ree
(
pRes
->
pGroupRec
);
t
f
ree
(
pRes
->
pColumnIndex
);
if
(
pRes
->
pArithSup
!=
NULL
)
{
t
aosTF
ree
(
pRes
->
pArithSup
->
data
);
t
aosTF
ree
(
pRes
->
pArithSup
);
t
f
ree
(
pRes
->
pArithSup
->
data
);
t
f
ree
(
pRes
->
pArithSup
);
}
pRes
->
data
=
NULL
;
// pRes->data points to the buffer of pRsp, no need to free
...
...
@@ -305,11 +305,11 @@ static void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeFromCache) {
freeQueryInfoImpl
(
pQueryInfo
);
clearAllTableMetaInfo
(
pQueryInfo
,
(
const
char
*
)
addr
,
removeFromCache
);
t
aosTF
ree
(
pQueryInfo
);
t
f
ree
(
pQueryInfo
);
}
pCmd
->
numOfClause
=
0
;
t
aosTF
ree
(
pCmd
->
pQueryInfo
);
t
f
ree
(
pCmd
->
pQueryInfo
);
}
void
tscResetSqlCmdObj
(
SSqlCmd
*
pCmd
,
bool
removeFromCache
)
{
...
...
@@ -387,14 +387,14 @@ void tscFreeTableMetaHelper(void *pTableMeta) {
assert
(
numOfEps
>=
0
&&
numOfEps
<=
TSDB_MAX_REPLICA
);
for
(
int32_t
i
=
0
;
i
<
numOfEps
;
++
i
)
{
t
aosTF
ree
(
p
->
vgroupInfo
.
epAddr
[
i
].
fqdn
);
t
f
ree
(
p
->
vgroupInfo
.
epAddr
[
i
].
fqdn
);
}
int32_t
numOfEps1
=
p
->
corVgroupInfo
.
numOfEps
;
assert
(
numOfEps1
>=
0
&&
numOfEps1
<=
TSDB_MAX_REPLICA
);
for
(
int32_t
i
=
0
;
i
<
numOfEps1
;
++
i
)
{
t
aosTF
ree
(
p
->
corVgroupInfo
.
epAddr
[
i
].
fqdn
);
t
f
ree
(
p
->
corVgroupInfo
.
epAddr
[
i
].
fqdn
);
}
}
...
...
@@ -418,9 +418,9 @@ void tscFreeSqlObj(SSqlObj* pSql) {
pSql
->
signature
=
NULL
;
pSql
->
fp
=
NULL
;
t
aosTF
ree
(
pSql
->
sqlstr
);
t
f
ree
(
pSql
->
sqlstr
);
t
aosTF
ree
(
pSql
->
pSubs
);
t
f
ree
(
pSql
->
pSubs
);
pSql
->
subState
.
numOfSub
=
0
;
pSql
->
self
=
0
;
...
...
@@ -428,7 +428,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
tscResetSqlCmdObj
(
pCmd
,
false
);
memset
(
pCmd
->
payload
,
0
,
(
size_t
)
pCmd
->
allocSize
);
t
aosTF
ree
(
pCmd
->
payload
);
t
f
ree
(
pCmd
->
payload
);
pCmd
->
allocSize
=
0
;
tsem_destroy
(
&
pSql
->
rspSem
);
...
...
@@ -440,15 +440,15 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
return
;
}
t
aosTF
ree
(
pDataBlock
->
pData
);
t
aosTF
ree
(
pDataBlock
->
params
);
t
f
ree
(
pDataBlock
->
pData
);
t
f
ree
(
pDataBlock
->
params
);
// free the refcount for metermeta
if
(
pDataBlock
->
pTableMeta
!=
NULL
)
{
taosCacheRelease
(
tscMetaCache
,
(
void
**
)
&
(
pDataBlock
->
pTableMeta
),
false
);
}
t
aosTF
ree
(
pDataBlock
);
t
f
ree
(
pDataBlock
);
}
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
int16_t
bytes
,
...
...
@@ -723,7 +723,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pTableDataBlockList) {
taosHashCleanup
(
pVnodeDataBlockHashList
);
tscDestroyBlockArrayList
(
pVnodeDataBlockList
);
t
aosTF
ree
(
dataBuf
->
pData
);
t
f
ree
(
dataBuf
->
pData
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
...
...
@@ -783,7 +783,7 @@ void tscCloseTscObj(void *param) {
pthread_mutex_destroy
(
&
pObj
->
mutex
);
tscDebug
(
"%p DB connection is closed, dnodeConn:%p"
,
pObj
,
p
);
t
aosTF
ree
(
pObj
);
t
f
ree
(
pObj
);
}
bool
tscIsInsertData
(
char
*
sqlstr
)
{
...
...
@@ -947,12 +947,12 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
if
(
pInfo
->
pArithExprInfo
!=
NULL
)
{
tExprTreeDestroy
(
&
pInfo
->
pArithExprInfo
->
pExpr
,
NULL
);
t
aosTF
ree
(
pInfo
->
pArithExprInfo
);
t
f
ree
(
pInfo
->
pArithExprInfo
);
}
}
taosArrayDestroy
(
pFieldInfo
->
internalField
);
t
aosTF
ree
(
pFieldInfo
->
final
);
t
f
ree
(
pFieldInfo
->
final
);
memset
(
pFieldInfo
,
0
,
sizeof
(
SFieldInfo
));
}
...
...
@@ -1068,7 +1068,7 @@ void* sqlExprDestroy(SSqlExpr* pExpr) {
tVariantDestroy
(
&
pExpr
->
param
[
i
]);
}
t
aosTF
ree
(
pExpr
);
t
f
ree
(
pExpr
);
return
NULL
;
}
...
...
@@ -1168,11 +1168,11 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
static
void
destroyFilterInfo
(
SColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilters
)
{
for
(
int32_t
i
=
0
;
i
<
numOfFilters
;
++
i
)
{
if
(
pFilterInfo
[
i
].
filterstr
)
{
t
aosTF
ree
(
pFilterInfo
[
i
].
pz
);
t
f
ree
(
pFilterInfo
[
i
].
pz
);
}
}
t
aosTF
ree
(
pFilterInfo
);
t
f
ree
(
pFilterInfo
);
}
SColumn
*
tscColumnClone
(
const
SColumn
*
src
)
{
...
...
@@ -1460,7 +1460,7 @@ void tscTagCondRelease(STagCond* pTagCond) {
size_t
s
=
taosArrayGetSize
(
pTagCond
->
pCond
);
for
(
int32_t
i
=
0
;
i
<
s
;
++
i
)
{
SCond
*
p
=
taosArrayGet
(
pTagCond
->
pCond
,
i
);
t
aosTF
ree
(
p
->
cond
);
t
f
ree
(
p
->
cond
);
}
taosArrayDestroy
(
pTagCond
->
pCond
);
...
...
@@ -1652,7 +1652,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) {
pQueryInfo
->
tsBuf
=
tsBufDestroy
(
pQueryInfo
->
tsBuf
);
t
aosTF
ree
(
pQueryInfo
->
fillVal
);
t
f
ree
(
pQueryInfo
->
fillVal
);
}
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
)
{
...
...
@@ -1672,7 +1672,7 @@ void tscFreeVgroupTableInfo(SArray* pVgroupTables) {
SVgroupTableInfo
*
pInfo
=
taosArrayGet
(
pVgroupTables
,
i
);
for
(
int32_t
j
=
0
;
j
<
pInfo
->
vgInfo
.
numOfEps
;
++
j
)
{
t
aosTF
ree
(
pInfo
->
vgInfo
.
epAddr
[
j
].
fqdn
);
t
f
ree
(
pInfo
->
vgInfo
.
epAddr
[
j
].
fqdn
);
}
taosArrayDestroy
(
pInfo
->
itemList
);
...
...
@@ -1689,7 +1689,7 @@ void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index) {
SVgroupTableInfo
*
pInfo
=
taosArrayGet
(
pVgroupTable
,
index
);
for
(
int32_t
j
=
0
;
j
<
pInfo
->
vgInfo
.
numOfEps
;
++
j
)
{
t
aosTF
ree
(
pInfo
->
vgInfo
.
epAddr
[
j
].
fqdn
);
t
f
ree
(
pInfo
->
vgInfo
.
epAddr
[
j
].
fqdn
);
}
taosArrayDestroy
(
pInfo
->
itemList
);
...
...
@@ -1737,7 +1737,7 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool rem
free
(
pTableMetaInfo
);
}
t
aosTF
ree
(
pQueryInfo
->
pTableMetaInfo
);
t
f
ree
(
pQueryInfo
->
pTableMetaInfo
);
}
STableMetaInfo
*
tscAddTableMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTableMeta
,
...
...
@@ -2336,7 +2336,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) {
pRes
->
numOfTotal
=
num
;
t
aosTF
ree
(
pSql
->
pSubs
);
t
f
ree
(
pSql
->
pSubs
);
pSql
->
subState
.
numOfSub
=
0
;
pSql
->
fp
=
fp
;
...
...
@@ -2461,11 +2461,11 @@ void* tscVgroupInfoClear(SVgroupsInfo *vgroupList) {
SVgroupInfo
*
pVgroupInfo
=
&
vgroupList
->
vgroups
[
i
];
for
(
int32_t
j
=
0
;
j
<
pVgroupInfo
->
numOfEps
;
++
j
)
{
t
aosTF
ree
(
pVgroupInfo
->
epAddr
[
j
].
fqdn
);
t
f
ree
(
pVgroupInfo
->
epAddr
[
j
].
fqdn
);
}
}
t
aosTF
ree
(
vgroupList
);
t
f
ree
(
vgroupList
);
return
NULL
;
}
...
...
@@ -2473,7 +2473,7 @@ void tscSVgroupInfoCopy(SVgroupInfo* dst, const SVgroupInfo* src) {
dst
->
vgId
=
src
->
vgId
;
dst
->
numOfEps
=
src
->
numOfEps
;
for
(
int32_t
i
=
0
;
i
<
dst
->
numOfEps
;
++
i
)
{
t
aosTF
ree
(
dst
->
epAddr
[
i
].
fqdn
);
t
f
ree
(
dst
->
epAddr
[
i
].
fqdn
);
dst
->
epAddr
[
i
].
port
=
src
->
epAddr
[
i
].
port
;
dst
->
epAddr
[
i
].
fqdn
=
strdup
(
src
->
epAddr
[
i
].
fqdn
);
}
...
...
src/common/inc/tdataformat.h
浏览文件 @
9e663ecd
...
...
@@ -80,7 +80,7 @@ typedef struct {
#define schemaFLen(s) ((s)->flen)
#define schemaVLen(s) ((s)->vlen)
#define schemaColAt(s, i) ((s)->columns + i)
#define tdFreeSchema(s) t
aosTF
ree((s))
#define tdFreeSchema(s) t
f
ree((s))
STSchema
*
tdDupSchema
(
STSchema
*
pSchema
);
int
tdEncodeSchema
(
void
**
buf
,
STSchema
*
pSchema
);
...
...
@@ -308,7 +308,7 @@ typedef struct {
#define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r))
#define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset)
#define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i))
#define kvRowFree(r) t
aosTF
ree(r)
#define kvRowFree(r) t
f
ree(r)
#define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r))
SKVRow
tdKVRowDup
(
SKVRow
row
);
...
...
src/common/src/tdataformat.c
浏览文件 @
9e663ecd
...
...
@@ -97,7 +97,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
void
tdDestroyTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
)
{
if
(
pBuilder
)
{
t
aosTF
ree
(
pBuilder
->
columns
);
t
f
ree
(
pBuilder
->
columns
);
}
}
...
...
@@ -339,8 +339,8 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
void
tdFreeDataCols
(
SDataCols
*
pCols
)
{
if
(
pCols
)
{
t
aosTF
ree
(
pCols
->
buf
);
t
aosTF
ree
(
pCols
->
cols
);
t
f
ree
(
pCols
->
buf
);
t
f
ree
(
pCols
->
cols
);
free
(
pCols
);
}
}
...
...
@@ -669,8 +669,8 @@ int tdInitKVRowBuilder(SKVRowBuilder *pBuilder) {
}
void
tdDestroyKVRowBuilder
(
SKVRowBuilder
*
pBuilder
)
{
t
aosTF
ree
(
pBuilder
->
pColIdx
);
t
aosTF
ree
(
pBuilder
->
buf
);
t
f
ree
(
pBuilder
->
pColIdx
);
t
f
ree
(
pBuilder
->
buf
);
}
void
tdResetKVRowBuilder
(
SKVRowBuilder
*
pBuilder
)
{
...
...
src/common/src/tvariant.c
浏览文件 @
9e663ecd
...
...
@@ -125,7 +125,7 @@ void tVariantDestroy(tVariant *pVar) {
if
(
pVar
==
NULL
)
return
;
if
(
pVar
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pVar
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
t
aosTF
ree
(
pVar
->
pz
);
t
f
ree
(
pVar
->
pz
);
pVar
->
nLen
=
0
;
}
...
...
src/cq/src/cqMain.c
浏览文件 @
9e663ecd
...
...
@@ -115,7 +115,7 @@ void cqClose(void *handle) {
SCqObj
*
pTemp
=
pObj
;
pObj
=
pObj
->
next
;
tdFreeSchema
(
pTemp
->
pSchema
);
t
aosTF
ree
(
pTemp
->
sqlStr
);
t
f
ree
(
pTemp
->
sqlStr
);
free
(
pTemp
);
}
...
...
src/dnode/src/dnodeMPeer.c
浏览文件 @
9e663ecd
...
...
@@ -84,7 +84,7 @@ void dnodeCleanupMPeer() {
taosCloseQset
(
tsMPeerQset
);
tsMPeerQset
=
NULL
;
t
aosTF
ree
(
tsMPeerWP
.
worker
);
t
f
ree
(
tsMPeerWP
.
worker
);
}
int32_t
dnodeAllocateMPeerQueue
()
{
...
...
src/dnode/src/dnodeMWrite.c
浏览文件 @
9e663ecd
...
...
@@ -86,7 +86,7 @@ void dnodeCleanupMWrite() {
taosCloseQset
(
tsMWriteQset
);
tsMWriteQset
=
NULL
;
t
aosTF
ree
(
tsMWriteWP
.
worker
);
t
f
ree
(
tsMWriteWP
.
worker
);
}
int32_t
dnodeAllocMWritequeue
()
{
...
...
src/inc/mnode.h
浏览文件 @
9e663ecd
...
...
@@ -47,6 +47,7 @@ typedef struct SMnodeMsg {
int8_t
successed
;
int8_t
expected
;
int8_t
retry
;
int32_t
incomingTs
;
int32_t
code
;
void
*
pObj
;
SRpcMsg
rpcMsg
;
...
...
src/inc/taoserror.h
浏览文件 @
9e663ecd
...
...
@@ -181,6 +181,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB, 0, 0x0383, "Invalid da
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MONITOR_DB_FORBIDDEN
,
0
,
0x0384
,
"Cannot delete monitor database"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_DATABASES
,
0
,
0x0385
,
"Too many databases for account"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DB_IN_DROPPING
,
0
,
0x0386
,
"Database not available"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_NOT_READY
,
0
,
0x0387
,
"Database unsynced"
)
// dnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MSG_NOT_PROCESSED
,
0
,
0x0400
,
"Message not processed"
)
...
...
src/kit/shell/inc/shell.h
浏览文件 @
9e663ecd
...
...
@@ -60,7 +60,7 @@ typedef struct SShellArguments {
extern
void
shellParseArgument
(
int
argc
,
char
*
argv
[],
SShellArguments
*
arguments
);
extern
TAOS
*
shellInit
(
SShellArguments
*
args
);
extern
void
*
shellLoopQuery
(
void
*
arg
);
extern
void
taos_error
(
TAOS_RES
*
tres
);
extern
void
taos_error
(
TAOS_RES
*
tres
,
int64_t
st
);
extern
int
regex_match
(
const
char
*
s
,
const
char
*
reg
,
int
cflags
);
void
shellReadCommand
(
TAOS
*
con
,
char
command
[]);
int32_t
shellRunCommand
(
TAOS
*
con
,
char
*
command
);
...
...
src/kit/shell/src/shellDarwin.c
浏览文件 @
9e663ecd
...
...
@@ -229,8 +229,8 @@ void shellReadCommand(TAOS *con, char *command) {
printf
(
"
\n
"
);
if
(
isReadyGo
(
&
cmd
))
{
sprintf
(
command
,
"%s%s"
,
cmd
.
buffer
,
cmd
.
command
);
t
aosTF
ree
(
cmd
.
buffer
);
t
aosTF
ree
(
cmd
.
command
);
t
f
ree
(
cmd
.
buffer
);
t
f
ree
(
cmd
.
command
);
return
;
}
else
{
updateBuffer
(
&
cmd
);
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
9e663ecd
...
...
@@ -193,7 +193,7 @@ int32_t shellRunCommand(TAOS* con, char* command) {
history
.
hist
[(
history
.
hend
+
MAX_HISTORY_SIZE
-
1
)
%
MAX_HISTORY_SIZE
]
==
NULL
||
strcmp
(
command
,
history
.
hist
[(
history
.
hend
+
MAX_HISTORY_SIZE
-
1
)
%
MAX_HISTORY_SIZE
])
!=
0
)
{
if
(
history
.
hist
[
history
.
hend
]
!=
NULL
)
{
t
aosTF
ree
(
history
.
hist
[
history
.
hend
]);
t
f
ree
(
history
.
hist
[
history
.
hend
]);
}
history
.
hist
[
history
.
hend
]
=
strdup
(
command
);
...
...
@@ -296,7 +296,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
TAOS_RES
*
pSql
=
taos_query_h
(
con
,
command
,
&
result
);
if
(
taos_errno
(
pSql
))
{
taos_error
(
pSql
);
taos_error
(
pSql
,
st
);
return
;
}
...
...
@@ -770,7 +770,7 @@ void read_history() {
return
;
}
while
((
read_size
=
t
aosG
etline
(
&
line
,
&
line_size
,
f
))
!=
-
1
)
{
while
((
read_size
=
t
g
etline
(
&
line
,
&
line_size
,
f
))
!=
-
1
)
{
line
[
read_size
-
1
]
=
'\0'
;
history
.
hist
[
history
.
hend
]
=
strdup
(
line
);
...
...
@@ -800,16 +800,17 @@ void write_history() {
for
(
int
i
=
history
.
hstart
;
i
!=
history
.
hend
;)
{
if
(
history
.
hist
[
i
]
!=
NULL
)
{
fprintf
(
f
,
"%s
\n
"
,
history
.
hist
[
i
]);
t
aosTF
ree
(
history
.
hist
[
i
]);
t
f
ree
(
history
.
hist
[
i
]);
}
i
=
(
i
+
1
)
%
MAX_HISTORY_SIZE
;
}
fclose
(
f
);
}
void
taos_error
(
TAOS_RES
*
tres
)
{
void
taos_error
(
TAOS_RES
*
tres
,
int64_t
st
)
{
int64_t
et
=
taosGetTimestampUs
();
atomic_store_ptr
(
&
result
,
0
);
fprintf
(
stderr
,
"
\n
DB error: %s
\n
"
,
taos_errstr
(
tres
)
);
fprintf
(
stderr
,
"
\n
DB error: %s
(%.6fs)
\n
"
,
taos_errstr
(
tres
),
(
et
-
st
)
/
1E6
);
taos_free_result
(
tres
);
}
...
...
@@ -853,7 +854,7 @@ void source_file(TAOS *con, char *fptr) {
return
;
}
while
((
read_len
=
t
aosG
etline
(
&
line
,
&
line_len
,
f
))
!=
-
1
)
{
while
((
read_len
=
t
g
etline
(
&
line
,
&
line_len
,
f
))
!=
-
1
)
{
if
(
read_len
>=
tsMaxSQLStringLen
)
continue
;
line
[
--
read_len
]
=
'\0'
;
...
...
src/kit/shell/src/shellLinux.c
浏览文件 @
9e663ecd
...
...
@@ -232,8 +232,8 @@ void shellReadCommand(TAOS *con, char *command) {
printf
(
"
\n
"
);
if
(
isReadyGo
(
&
cmd
))
{
sprintf
(
command
,
"%s%s"
,
cmd
.
buffer
,
cmd
.
command
);
t
aosTF
ree
(
cmd
.
buffer
);
t
aosTF
ree
(
cmd
.
command
);
t
f
ree
(
cmd
.
buffer
);
t
f
ree
(
cmd
.
command
);
return
;
}
else
{
updateBuffer
(
&
cmd
);
...
...
@@ -351,7 +351,7 @@ void *shellLoopQuery(void *arg) {
reset_terminal_mode
();
}
while
(
shellRunCommand
(
con
,
command
)
==
0
);
t
aosTF
ree
(
command
);
t
f
ree
(
command
);
exitShell
();
pthread_cleanup_pop
(
1
);
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
9e663ecd
...
...
@@ -955,7 +955,7 @@ void querySqlFile(TAOS* taos, char* sqlFile)
double
t
=
getCurrentTime
();
while
((
read_len
=
t
aosG
etline
(
&
line
,
&
line_len
,
fp
))
!=
-
1
)
{
while
((
read_len
=
t
g
etline
(
&
line
,
&
line_len
,
fp
))
!=
-
1
)
{
if
(
read_len
>=
MAX_SQL_SIZE
)
continue
;
line
[
--
read_len
]
=
'\0'
;
...
...
src/mnode/src/mnodeAcct.c
浏览文件 @
9e663ecd
...
...
@@ -34,7 +34,7 @@ static int32_t mnodeCreateRootAcct();
static
int32_t
mnodeAcctActionDestroy
(
SSdbOper
*
pOper
)
{
SAcctObj
*
pAcct
=
pOper
->
pObj
;
pthread_mutex_destroy
(
&
pAcct
->
mutex
);
t
aosTF
ree
(
pOper
->
pObj
);
t
f
ree
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/mnode/src/mnodeCluster.c
浏览文件 @
9e663ecd
...
...
@@ -33,7 +33,7 @@ static int32_t mnodeGetClusterMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *
static
int32_t
mnodeRetrieveClusters
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeClusterActionDestroy
(
SSdbOper
*
pOper
)
{
t
aosTF
ree
(
pOper
->
pObj
);
t
f
ree
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
9e663ecd
...
...
@@ -52,8 +52,8 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg);
static
void
mnodeDestroyDb
(
SDbObj
*
pDb
)
{
pthread_mutex_destroy
(
&
pDb
->
mutex
);
t
aosTF
ree
(
pDb
->
vgList
);
t
aosTF
ree
(
pDb
);
t
f
ree
(
pDb
->
vgList
);
t
f
ree
(
pDb
);
}
static
int32_t
mnodeDbActionDestroy
(
SSdbOper
*
pOper
)
{
...
...
@@ -405,7 +405,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
code
=
mnodeCheckDbCfg
(
&
pDb
->
cfg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
t
aosTF
ree
(
pDb
);
t
f
ree
(
pDb
);
return
code
;
}
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
9e663ecd
...
...
@@ -88,7 +88,7 @@ static char* offlineReason[] = {
};
static
int32_t
mnodeDnodeActionDestroy
(
SSdbOper
*
pOper
)
{
t
aosTF
ree
(
pOper
->
pObj
);
t
f
ree
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -655,7 +655,7 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
int32_t
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
int
dnodeId
=
pDnode
->
dnodeId
;
t
aosTF
ree
(
pDnode
);
t
f
ree
(
pDnode
);
mError
(
"failed to create dnode:%d, reason:%s"
,
dnodeId
,
tstrerror
(
code
));
}
else
{
mLInfo
(
"dnode:%d is created"
,
pDnode
->
dnodeId
);
...
...
src/mnode/src/mnodeInt.c
浏览文件 @
9e663ecd
...
...
@@ -40,6 +40,7 @@ void *mnodeCreateMsg(SRpcMsg *pRpcMsg) {
pMsg
->
rpcMsg
=
*
pRpcMsg
;
pMsg
->
rpcMsg
.
pCont
=
pMsg
->
pCont
;
pMsg
->
incomingTs
=
taosGetTimestampSec
();
memcpy
(
pMsg
->
pCont
,
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
);
return
pMsg
;
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
9e663ecd
...
...
@@ -59,7 +59,7 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
#endif
static
int32_t
mnodeMnodeActionDestroy
(
SSdbOper
*
pOper
)
{
t
aosTF
ree
(
pOper
->
pObj
);
t
f
ree
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -342,14 +342,14 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
t
aosTF
ree
(
pMnode
);
t
f
ree
(
pMnode
);
return
;
}
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"dnode:%d, failed to create mnode, ep:%s reason:%s"
,
dnodeId
,
dnodeEp
,
tstrerror
(
code
));
t
aosTF
ree
(
pMnode
);
t
f
ree
(
pMnode
);
}
}
...
...
src/mnode/src/mnodeProfile.c
浏览文件 @
9e663ecd
...
...
@@ -131,8 +131,8 @@ SConnObj *mnodeAccquireConn(int32_t connId, char *user, uint32_t ip, uint16_t po
static
void
mnodeFreeConn
(
void
*
data
)
{
SConnObj
*
pConn
=
data
;
t
aosTF
ree
(
pConn
->
pQueries
);
t
aosTF
ree
(
pConn
->
pStreams
);
t
f
ree
(
pConn
->
pQueries
);
t
f
ree
(
pConn
->
pStreams
);
mDebug
(
"connId:%d, is destroyed"
,
pConn
->
connId
);
}
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
9e663ecd
...
...
@@ -984,7 +984,7 @@ void sdbCleanupWriteWorker() {
}
sdbFreeWritequeue
();
t
aosTF
ree
(
tsSdbPool
.
writeWorker
);
t
f
ree
(
tsSdbPool
.
writeWorker
);
mInfo
(
"sdb write is closed"
);
}
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
9e663ecd
...
...
@@ -415,7 +415,7 @@ static void mnodeFreeShowObj(void *data) {
sdbFreeIter
(
pShow
->
pIter
);
mDebug
(
"%p, show is destroyed, data:%p index:%d"
,
pShow
,
data
,
pShow
->
index
);
t
aosTF
ree
(
pShow
);
t
f
ree
(
pShow
);
}
static
void
mnodeReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
)
{
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
9e663ecd
...
...
@@ -45,6 +45,10 @@
#include "mnodeRead.h"
#include "mnodePeer.h"
#define ALTER_CTABLE_RETRY_TIMES 3
#define CREATE_CTABLE_RETRY_TIMES 10
#define CREATE_CTABLE_RETRY_SEC 14
static
void
*
tsChildTableSdb
;
static
void
*
tsSuperTableSdb
;
static
int32_t
tsChildTableUpdateSize
;
...
...
@@ -89,10 +93,10 @@ static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg);
static
int32_t
mnodeFindSuperTableColumnIndex
(
SSTableObj
*
pStable
,
char
*
colName
);
static
void
mnodeDestroyChildTable
(
SCTableObj
*
pTable
)
{
t
aosTF
ree
(
pTable
->
info
.
tableId
);
t
aosTF
ree
(
pTable
->
schema
);
t
aosTF
ree
(
pTable
->
sql
);
t
aosTF
ree
(
pTable
);
t
f
ree
(
pTable
->
info
.
tableId
);
t
f
ree
(
pTable
->
schema
);
t
f
ree
(
pTable
->
sql
);
t
f
ree
(
pTable
);
}
static
int32_t
mnodeChildTableActionDestroy
(
SSdbOper
*
pOper
)
{
...
...
@@ -421,9 +425,9 @@ static void mnodeDestroySuperTable(SSTableObj *pStable) {
taosHashCleanup
(
pStable
->
vgHash
);
pStable
->
vgHash
=
NULL
;
}
t
aosTF
ree
(
pStable
->
info
.
tableId
);
t
aosTF
ree
(
pStable
->
schema
);
t
aosTF
ree
(
pStable
);
t
f
ree
(
pStable
->
info
.
tableId
);
t
f
ree
(
pStable
->
schema
);
t
f
ree
(
pStable
);
}
static
int32_t
mnodeSuperTableActionDestroy
(
SSdbOper
*
pOper
)
{
...
...
@@ -2421,7 +2425,9 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
code
);
}
}
else
{
if
(
mnodeMsg
->
retry
++
<
10
)
{
mnodeMsg
->
retry
++
;
int32_t
sec
=
taosGetTimestampSec
();
if
(
mnodeMsg
->
retry
<
CREATE_CTABLE_RETRY_TIMES
&&
ABS
(
sec
-
mnodeMsg
->
incomingTs
)
<
CREATE_CTABLE_RETRY_SEC
)
{
mDebug
(
"app:%p:%p, table:%s, create table rsp received, need retry, times:%d vgId:%d sid:%d uid:%"
PRIu64
" result:%s thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
retry
,
pTable
->
vgId
,
pTable
->
tid
,
...
...
@@ -2429,13 +2435,18 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
dnodeDelayReprocessMWriteMsg
(
mnodeMsg
);
}
else
{
mError
(
"app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%"
PRIu64
", result:%s thandle:%p"
,
mError
(
"app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%"
PRIu64
", result:%s thandle:%p incomingTs:%d curTs:%d retryTimes:%d"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
pTable
->
vgId
,
pTable
->
tid
,
pTable
->
uid
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
);
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
,
mnodeMsg
->
incomingTs
,
sec
,
mnodeMsg
->
retry
);
SSdbOper
oper
=
{.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsChildTableSdb
,
.
pObj
=
pTable
};
sdbDeleteRow
(
&
oper
);
if
(
rpcMsg
->
code
==
TSDB_CODE_APP_NOT_READY
)
{
//Avoid retry again in client
rpcMsg
->
code
=
TSDB_CODE_MND_VGROUP_NOT_READY
;
}
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
}
}
...
...
@@ -2456,7 +2467,7 @@ static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg) {
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
TSDB_CODE_SUCCESS
);
}
else
{
if
(
mnodeMsg
->
retry
++
<
3
)
{
if
(
mnodeMsg
->
retry
++
<
ALTER_CTABLE_RETRY_TIMES
)
{
mDebug
(
"app:%p:%p, table:%s, alter table rsp received, need retry, times:%d result:%s thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
retry
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
);
...
...
src/mnode/src/mnodeUser.c
浏览文件 @
9e663ecd
...
...
@@ -43,7 +43,7 @@ static int32_t mnodeProcessDropUserMsg(SMnodeMsg *pMsg);
static
int32_t
mnodeProcessAuthMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeUserActionDestroy
(
SSdbOper
*
pOper
)
{
t
aosTF
ree
(
pOper
->
pObj
);
t
f
ree
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -270,7 +270,7 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"user:%s, failed to create by %s, reason:%s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
),
tstrerror
(
code
));
t
aosTF
ree
(
pUser
);
t
f
ree
(
pUser
);
}
else
{
mLInfo
(
"user:%s, is created by %s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
));
}
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
9e663ecd
...
...
@@ -69,7 +69,7 @@ static void mnodeDestroyVgroup(SVgObj *pVgroup) {
pVgroup
->
idPool
=
NULL
;
}
t
aosTF
ree
(
pVgroup
);
t
f
ree
(
pVgroup
);
}
static
int32_t
mnodeVgroupActionDestroy
(
SSdbOper
*
pOper
)
{
...
...
src/os/inc/os.h
浏览文件 @
9e663ecd
...
...
@@ -53,7 +53,6 @@ extern "C" {
#endif
#include "osDef.h"
#include "osAlloc.h"
#include "osAtomic.h"
#include "osCommon.h"
#include "osDir.h"
...
...
src/os/inc/osAlloc.h
已删除
100644 → 0
浏览文件 @
2554a1b5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_OS_ALLOC_H
#define TDENGINE_OS_ALLOC_H
#ifdef __cplusplus
extern
"C"
{
#endif
#ifndef TAOS_OS_FUNC_ALLOC
#define tmalloc(size) malloc(size)
#define tcalloc(nmemb, size) calloc(nmemb, size)
#define trealloc(p, size) realloc(p, size)
#define tmemalign(alignment, size) malloc(size)
#define tfree(p) free(p)
#define tmemzero(p, size) memset(p, 0, size)
#else
void
*
tmalloc
(
int32_t
size
);
void
*
tcalloc
(
int32_t
nmemb
,
int32_t
size
);
void
*
trealloc
(
void
*
p
,
int32_t
size
);
void
*
tmemalign
(
int32_t
alignment
,
int32_t
size
);
void
tfree
(
void
*
p
);
void
tmemzero
(
void
*
p
,
int32_t
size
);
#endif
#ifdef __cplusplus
}
#endif
#endif
src/os/inc/osMemory.h
浏览文件 @
9e663ecd
...
...
@@ -31,6 +31,7 @@ typedef enum {
void
taosSetAllocMode
(
int
mode
,
const
char
*
path
,
bool
autoDump
);
void
taosDumpMemoryLeak
();
// used in tsdb module
void
*
taosTMalloc
(
size_t
size
);
void
*
taosTCalloc
(
size_t
nmemb
,
size_t
size
);
void
*
taosTRealloc
(
void
*
ptr
,
size_t
size
);
...
...
@@ -38,7 +39,14 @@ void taosTZfree(void *ptr);
size_t
taosTSizeof
(
void
*
ptr
);
void
taosTMemset
(
void
*
ptr
,
int
c
);
#define taosTFree(x) \
// used in other module
#define tmalloc(size) malloc(size)
#define tcalloc(num, size) calloc(num, size)
#define trealloc(ptr, size) realloc(ptr, size)
#define tstrdup(str) taosStrdupImp(str)
#define tstrndup(str, size) taosStrndupImp(str, size)
#define tgetline(lineptr, n, stream) taosGetlineImp(lineptr, n, stream)
#define tfree(x) \
do { \
if (x) { \
free((void *)(x)); \
...
...
@@ -46,37 +54,30 @@ void taosTMemset(void *ptr, int c);
} \
} while (0);
#define taosMalloc(size) malloc(size)
#define taosCalloc(num, size) calloc(num, size)
#define taosRealloc(ptr, size) realloc(ptr, size)
#define taosFree(ptr) free(ptr)
#define taosStrdup(str) taosStrdupImp(str)
#define taosStrndup(str, size) taosStrndupImp(str, size)
#define taosGetline(lineptr, n, stream) taosGetlineImp(lineptr, n, stream)
#ifdef TAOS_MEM_CHECK
#ifdef TAOS_MEM_CHECK_TEST
void
*
taos_malloc
(
size_t
size
,
const
char
*
file
,
uint32_t
line
);
void
*
taos_calloc
(
size_t
num
,
size_t
size
,
const
char
*
file
,
uint32_t
line
);
void
*
taos_realloc
(
void
*
ptr
,
size_t
size
,
const
char
*
file
,
uint32_t
line
);
void
taos_free
(
void
*
ptr
,
const
char
*
file
,
uint32_t
line
);
char
*
taos_strdup
(
const
char
*
str
,
const
char
*
file
,
uint32_t
line
);
char
*
taos_strndup
(
const
char
*
str
,
size_t
size
,
const
char
*
file
,
uint32_t
line
);
ssize_t
taos_getline
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
const
char
*
file
,
uint32_t
line
);
#undef taosMalloc
#undef taosCalloc
#undef taosRealloc
#undef taosFree
#undef taosStrdup
#undef taosStrndup
#undef taosGetline
#define taosMalloc(size) taos_malloc(size, __FILE__, __LINE__)
#define taosCalloc(num, size) taos_calloc(num, size, __FILE__, __LINE__)
#define taosRealloc(ptr, size) taos_realloc(ptr, size, __FILE__, __LINE__)
#define taosFree(ptr) taos_free(ptr, __FILE__, __LINE__)
//#define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__)
//#define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__)
//#define taosGetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__)
void
*
taosMallocMem
(
size_t
size
,
const
char
*
file
,
uint32_t
line
);
void
*
taosCallocMem
(
size_t
num
,
size_t
size
,
const
char
*
file
,
uint32_t
line
);
void
*
taosReallocMem
(
void
*
ptr
,
size_t
size
,
const
char
*
file
,
uint32_t
line
);
void
taosFreeMem
(
void
*
ptr
,
const
char
*
file
,
uint32_t
line
);
char
*
taosStrdupMem
(
const
char
*
str
,
const
char
*
file
,
uint32_t
line
);
char
*
taosStrndupMem
(
const
char
*
str
,
size_t
size
,
const
char
*
file
,
uint32_t
line
);
ssize_t
taosGetlineMem
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
const
char
*
file
,
uint32_t
line
);
#undef tmalloc
#undef tcalloc
#undef trealloc
#undef tfree
#define tmalloc(size) taosMallocMem(size, __FILE__, __LINE__)
#define tcalloc(num, size) taosCallocMem(num, size, __FILE__, __LINE__)
#define trealloc(ptr, size) taosReallocMem(ptr, size, __FILE__, __LINE__)
#define tfree(ptr) taosFreeMem(ptr, __FILE__, __LINE__)
// #undef tstrdup
// #undef tstrndup
// #undef tgetline
// #define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__)
// #define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__)
// #define tgetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__)
#endif
#endif
...
...
src/os/src/detail/osAlloc.c
已删除
100644 → 0
浏览文件 @
2554a1b5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tulog.h"
#include "osAlloc.h"
#define TSDB_HAVE_MEMALIGN
#ifdef TAOS_OS_FUNC_ALLOC
void
*
tmalloc
(
int32_t
size
)
{
void
*
p
=
malloc
(
size
);
if
(
p
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to malloc memory, size:%d reason:%s"
,
size
,
strerror
(
errno
));
}
return
p
;
}
void
*
tcalloc
(
int32_t
nmemb
,
int32_t
size
)
{
void
*
p
=
calloc
(
nmemb
,
size
);
if
(
p
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to calloc memory, nmemb:%d size:%d reason:%s"
,
nmemb
,
size
,
strerror
(
errno
));
}
return
p
;
}
void
*
trealloc
(
void
*
p
,
int32_t
size
)
{
p
=
realloc
(
p
,
size
);
if
(
p
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to realloc memory, size:%d reason:%s"
,
size
,
strerror
(
errno
));
}
return
p
;
}
void
tfree
(
void
*
p
)
{
free
(
p
);
}
void
tmemzero
(
void
*
p
,
int32_t
size
)
{
memset
(
p
,
0
,
size
);
}
#ifdef TSDB_HAVE_MEMALIGN
void
*
tmemalign
(
int32_t
alignment
,
int32_t
size
)
{
void
*
p
;
int
err
=
posix_memalign
(
&
p
,
alignment
,
size
);
if
(
err
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to memalign memory, alignment:%d size:%d reason:%s"
,
alignment
,
size
,
strerror
(
err
));
p
=
NULL
;
}
return
p
;
}
#else
void
*
tmemalign
(
int32_t
alignment
,
int32_t
size
)
{
return
tmalloc
(
size
);
}
#endif
#endif
\ No newline at end of file
src/os/src/detail/osMemory.c
浏览文件 @
9e663ecd
...
...
@@ -28,7 +28,7 @@ static FILE* fpAllocLog = NULL;
extern
int32_t
taosGetTimestampSec
();
static
int32_t
startTime
=
INT32_MAX
;
static
bool
random_alloc_f
ail
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
static
bool
taosRandomAllocF
ail
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
if
(
taosGetTimestampSec
()
<
startTime
)
{
return
false
;
}
...
...
@@ -48,33 +48,33 @@ static bool random_alloc_fail(size_t size, const char* file, uint32_t line) {
return
true
;
}
static
void
*
malloc_random
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
return
random_alloc_f
ail
(
size
,
file
,
line
)
?
NULL
:
malloc
(
size
);
static
void
*
taosRandmoMalloc
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
return
taosRandomAllocF
ail
(
size
,
file
,
line
)
?
NULL
:
malloc
(
size
);
}
static
void
*
calloc_random
(
size_t
num
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
return
random_alloc_f
ail
(
num
*
size
,
file
,
line
)
?
NULL
:
calloc
(
num
,
size
);
static
void
*
taosRandomCalloc
(
size_t
num
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
return
taosRandomAllocF
ail
(
num
*
size
,
file
,
line
)
?
NULL
:
calloc
(
num
,
size
);
}
static
void
*
realloc_random
(
void
*
ptr
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
return
random_alloc_f
ail
(
size
,
file
,
line
)
?
NULL
:
realloc
(
ptr
,
size
);
static
void
*
taosRandomRealloc
(
void
*
ptr
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
return
taosRandomAllocF
ail
(
size
,
file
,
line
)
?
NULL
:
realloc
(
ptr
,
size
);
}
static
char
*
strdup_random
(
const
char
*
str
,
const
char
*
file
,
uint32_t
line
)
{
static
char
*
taosRandomStrdup
(
const
char
*
str
,
const
char
*
file
,
uint32_t
line
)
{
size_t
len
=
strlen
(
str
);
return
random_alloc_f
ail
(
len
+
1
,
file
,
line
)
?
NULL
:
taosStrdupImp
(
str
);
return
taosRandomAllocF
ail
(
len
+
1
,
file
,
line
)
?
NULL
:
taosStrdupImp
(
str
);
}
static
char
*
strndup_random
(
const
char
*
str
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
static
char
*
taosRandomStrndup
(
const
char
*
str
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
size_t
len
=
strlen
(
str
);
if
(
len
>
size
)
{
len
=
size
;
}
return
random_alloc_f
ail
(
len
+
1
,
file
,
line
)
?
NULL
:
taosStrndupImp
(
str
,
len
);
return
taosRandomAllocF
ail
(
len
+
1
,
file
,
line
)
?
NULL
:
taosStrndupImp
(
str
,
len
);
}
static
ssize_t
getline_random
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
const
char
*
file
,
uint32_t
line
)
{
return
random_alloc_f
ail
(
*
n
,
file
,
line
)
?
-
1
:
taosGetlineImp
(
lineptr
,
n
,
stream
);
static
ssize_t
taosRandomGetline
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
const
char
*
file
,
uint32_t
line
)
{
return
taosRandomAllocF
ail
(
*
n
,
file
,
line
)
?
-
1
:
taosGetlineImp
(
lineptr
,
n
,
stream
);
}
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -96,7 +96,7 @@ typedef struct SMemBlock {
static
SMemBlock
*
blocks
=
NULL
;
static
uintptr_t
lock
=
0
;
static
void
add_mem_b
lock
(
SMemBlock
*
blk
)
{
static
void
taosAddMemB
lock
(
SMemBlock
*
blk
)
{
blk
->
prev
=
NULL
;
while
(
atomic_val_compare_exchange_ptr
(
&
lock
,
0
,
1
)
!=
0
);
blk
->
next
=
blocks
;
...
...
@@ -107,7 +107,7 @@ static void add_mem_block(SMemBlock* blk) {
atomic_store_ptr
(
&
lock
,
0
);
}
static
void
remove_mem_b
lock
(
SMemBlock
*
blk
)
{
static
void
taosRemoveMemB
lock
(
SMemBlock
*
blk
)
{
while
(
atomic_val_compare_exchange_ptr
(
&
lock
,
0
,
1
)
!=
0
);
if
(
blocks
==
blk
)
{
...
...
@@ -126,7 +126,7 @@ static void remove_mem_block(SMemBlock* blk) {
blk
->
next
=
NULL
;
}
static
void
free_detect_l
eak
(
void
*
ptr
,
const
char
*
file
,
uint32_t
line
)
{
static
void
taosFreeDetectL
eak
(
void
*
ptr
,
const
char
*
file
,
uint32_t
line
)
{
if
(
ptr
==
NULL
)
{
return
;
}
...
...
@@ -140,11 +140,11 @@ static void free_detect_leak(void* ptr, const char* file, uint32_t line) {
return
;
}
remove_mem_b
lock
(
blk
);
taosRemoveMemB
lock
(
blk
);
free
(
blk
);
}
static
void
*
malloc_detect_l
eak
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
static
void
*
taosMallocDetectL
eak
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
if
(
size
==
0
)
{
return
NULL
;
}
...
...
@@ -166,28 +166,28 @@ static void* malloc_detect_leak(size_t size, const char* file, uint32_t line) {
blk
->
line
=
(
uint16_t
)
line
;
blk
->
magic
=
MEMBLK_MAGIC
;
blk
->
size
=
size
;
add_mem_b
lock
(
blk
);
taosAddMemB
lock
(
blk
);
return
blk
->
data
;
}
static
void
*
calloc_detect_l
eak
(
size_t
num
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
static
void
*
taosCallocDetectL
eak
(
size_t
num
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
size
*=
num
;
void
*
p
=
malloc_detect_l
eak
(
size
,
file
,
line
);
void
*
p
=
taosMallocDetectL
eak
(
size
,
file
,
line
);
if
(
p
!=
NULL
)
{
memset
(
p
,
0
,
size
);
}
return
p
;
}
static
void
*
realloc_detect_l
eak
(
void
*
ptr
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
static
void
*
taosReallocDetectL
eak
(
void
*
ptr
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
if
(
size
==
0
)
{
free_detect_l
eak
(
ptr
,
file
,
line
);
taosFreeDetectL
eak
(
ptr
,
file
,
line
);
return
NULL
;
}
if
(
ptr
==
NULL
)
{
return
malloc_detect_l
eak
(
size
,
file
,
line
);
return
taosMallocDetectL
eak
(
size
,
file
,
line
);
}
SMemBlock
*
blk
=
(
SMemBlock
*
)((
char
*
)
ptr
)
-
sizeof
(
SMemBlock
);
...
...
@@ -198,11 +198,11 @@ static void* realloc_detect_leak(void* ptr, size_t size, const char* file, uint3
return
realloc
(
ptr
,
size
);
}
remove_mem_b
lock
(
blk
);
taosRemoveMemB
lock
(
blk
);
void
*
p
=
realloc
(
blk
,
size
+
sizeof
(
SMemBlock
));
if
(
p
==
NULL
)
{
add_mem_b
lock
(
blk
);
taosAddMemB
lock
(
blk
);
return
NULL
;
}
...
...
@@ -212,13 +212,13 @@ static void* realloc_detect_leak(void* ptr, size_t size, const char* file, uint3
blk
=
(
SMemBlock
*
)
p
;
blk
->
size
=
size
;
add_mem_b
lock
(
blk
);
taosAddMemB
lock
(
blk
);
return
blk
->
data
;
}
static
char
*
strdup_detect_l
eak
(
const
char
*
str
,
const
char
*
file
,
uint32_t
line
)
{
static
char
*
taosStrdupDetectL
eak
(
const
char
*
str
,
const
char
*
file
,
uint32_t
line
)
{
size_t
len
=
strlen
(
str
);
char
*
p
=
malloc_detect_l
eak
(
len
+
1
,
file
,
line
);
char
*
p
=
taosMallocDetectL
eak
(
len
+
1
,
file
,
line
);
if
(
p
!=
NULL
)
{
memcpy
(
p
,
str
,
len
);
p
[
len
]
=
0
;
...
...
@@ -226,12 +226,12 @@ static char* strdup_detect_leak(const char* str, const char* file, uint32_t line
return
p
;
}
static
char
*
strndup_detect_l
eak
(
const
char
*
str
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
static
char
*
taosStrndupDetectL
eak
(
const
char
*
str
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
size_t
len
=
strlen
(
str
);
if
(
len
>
size
)
{
len
=
size
;
}
char
*
p
=
malloc_detect_l
eak
(
len
+
1
,
file
,
line
);
char
*
p
=
taosMallocDetectL
eak
(
len
+
1
,
file
,
line
);
if
(
p
!=
NULL
)
{
memcpy
(
p
,
str
,
len
);
p
[
len
]
=
0
;
...
...
@@ -239,13 +239,13 @@ static char* strndup_detect_leak(const char* str, size_t size, const char* file,
return
p
;
}
static
ssize_t
getline_detect_l
eak
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
const
char
*
file
,
uint32_t
line
)
{
static
ssize_t
taosGetlineDetectL
eak
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
const
char
*
file
,
uint32_t
line
)
{
char
*
buf
=
NULL
;
size_t
bufSize
=
0
;
ssize_t
size
=
taosGetlineImp
(
&
buf
,
&
bufSize
,
stream
);
if
(
size
!=
-
1
)
{
if
(
*
n
<
size
+
1
)
{
void
*
p
=
realloc_detect_l
eak
(
*
lineptr
,
size
+
1
,
file
,
line
);
void
*
p
=
taosReallocDetectL
eak
(
*
lineptr
,
size
+
1
,
file
,
line
);
if
(
p
==
NULL
)
{
free
(
buf
);
return
-
1
;
...
...
@@ -260,7 +260,7 @@ static ssize_t getline_detect_leak(char **lineptr, size_t *n, FILE *stream, cons
return
size
;
}
static
void
dump_memory_leak
()
{
static
void
taosDumpMemoryLeakImp
()
{
const
char
*
hex
=
"0123456789ABCDEF"
;
const
char
*
fmt
=
":%d: addr=%p, size=%d, content(first 16 bytes)="
;
size_t
numOfBlk
=
0
,
totalSize
=
0
;
...
...
@@ -299,7 +299,7 @@ static void dump_memory_leak() {
fflush
(
fpAllocLog
);
}
static
void
dump_memory_leak_on_s
ig
(
int
sig
)
{
static
void
taosDumpMemoryLeakOnS
ig
(
int
sig
)
{
fprintf
(
fpAllocLog
,
"signal %d received.
\n
"
,
sig
);
// restore default signal handler
...
...
@@ -307,55 +307,55 @@ static void dump_memory_leak_on_sig(int sig) {
act
.
sa_handler
=
SIG_DFL
;
sigaction
(
sig
,
&
act
,
NULL
);
dump_memory_leak
();
taosDumpMemoryLeakImp
();
}
////////////////////////////////////////////////////////////////////////////////
// interface functions
void
*
taos
_malloc
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
void
*
taos
MallocMem
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
switch
(
allocMode
)
{
case
TAOS_ALLOC_MODE_DEFAULT
:
return
malloc
(
size
);
case
TAOS_ALLOC_MODE_RANDOM_FAIL
:
return
malloc_random
(
size
,
file
,
line
);
return
taosRandmoMalloc
(
size
,
file
,
line
);
case
TAOS_ALLOC_MODE_DETECT_LEAK
:
return
malloc_detect_l
eak
(
size
,
file
,
line
);
return
taosMallocDetectL
eak
(
size
,
file
,
line
);
}
return
malloc
(
size
);
}
void
*
taos
_calloc
(
size_t
num
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
void
*
taos
CallocMem
(
size_t
num
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
switch
(
allocMode
)
{
case
TAOS_ALLOC_MODE_DEFAULT
:
return
calloc
(
num
,
size
);
case
TAOS_ALLOC_MODE_RANDOM_FAIL
:
return
calloc_random
(
num
,
size
,
file
,
line
);
return
taosRandomCalloc
(
num
,
size
,
file
,
line
);
case
TAOS_ALLOC_MODE_DETECT_LEAK
:
return
calloc_detect_l
eak
(
num
,
size
,
file
,
line
);
return
taosCallocDetectL
eak
(
num
,
size
,
file
,
line
);
}
return
calloc
(
num
,
size
);
}
void
*
taos
_realloc
(
void
*
ptr
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
void
*
taos
ReallocMem
(
void
*
ptr
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
switch
(
allocMode
)
{
case
TAOS_ALLOC_MODE_DEFAULT
:
return
realloc
(
ptr
,
size
);
case
TAOS_ALLOC_MODE_RANDOM_FAIL
:
return
realloc_random
(
ptr
,
size
,
file
,
line
);
return
taosRandomRealloc
(
ptr
,
size
,
file
,
line
);
case
TAOS_ALLOC_MODE_DETECT_LEAK
:
return
realloc_detect_l
eak
(
ptr
,
size
,
file
,
line
);
return
taosReallocDetectL
eak
(
ptr
,
size
,
file
,
line
);
}
return
realloc
(
ptr
,
size
);
}
void
taos
_free
(
void
*
ptr
,
const
char
*
file
,
uint32_t
line
)
{
void
taos
FreeMem
(
void
*
ptr
,
const
char
*
file
,
uint32_t
line
)
{
switch
(
allocMode
)
{
case
TAOS_ALLOC_MODE_DEFAULT
:
return
free
(
ptr
);
...
...
@@ -364,54 +364,54 @@ void taos_free(void* ptr, const char* file, uint32_t line) {
return
free
(
ptr
);
case
TAOS_ALLOC_MODE_DETECT_LEAK
:
return
free_detect_l
eak
(
ptr
,
file
,
line
);
return
taosFreeDetectL
eak
(
ptr
,
file
,
line
);
}
return
free
(
ptr
);
}
char
*
taos
_strdup
(
const
char
*
str
,
const
char
*
file
,
uint32_t
line
)
{
char
*
taos
StrdupMem
(
const
char
*
str
,
const
char
*
file
,
uint32_t
line
)
{
switch
(
allocMode
)
{
case
TAOS_ALLOC_MODE_DEFAULT
:
return
taosStrdupImp
(
str
);
case
TAOS_ALLOC_MODE_RANDOM_FAIL
:
return
strdup_random
(
str
,
file
,
line
);
return
taosRandomStrdup
(
str
,
file
,
line
);
case
TAOS_ALLOC_MODE_DETECT_LEAK
:
return
strdup_detect_l
eak
(
str
,
file
,
line
);
return
taosStrdupDetectL
eak
(
str
,
file
,
line
);
}
return
taosStrdupImp
(
str
);
}
char
*
taos
_strndup
(
const
char
*
str
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
char
*
taos
StrndupMem
(
const
char
*
str
,
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
switch
(
allocMode
)
{
case
TAOS_ALLOC_MODE_DEFAULT
:
return
taosStrndupImp
(
str
,
size
);
case
TAOS_ALLOC_MODE_RANDOM_FAIL
:
return
strndup_random
(
str
,
size
,
file
,
line
);
return
taosRandomStrndup
(
str
,
size
,
file
,
line
);
case
TAOS_ALLOC_MODE_DETECT_LEAK
:
return
strndup_detect_l
eak
(
str
,
size
,
file
,
line
);
return
taosStrndupDetectL
eak
(
str
,
size
,
file
,
line
);
}
return
taosStrndupImp
(
str
,
size
);
}
ssize_t
taos
_getline
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
const
char
*
file
,
uint32_t
line
)
{
ssize_t
taos
GetlineMem
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
,
const
char
*
file
,
uint32_t
line
)
{
switch
(
allocMode
)
{
case
TAOS_ALLOC_MODE_DEFAULT
:
return
taosGetlineImp
(
lineptr
,
n
,
stream
);
case
TAOS_ALLOC_MODE_RANDOM_FAIL
:
return
getline_random
(
lineptr
,
n
,
stream
,
file
,
line
);
return
taosRandomGetline
(
lineptr
,
n
,
stream
,
file
,
line
);
case
TAOS_ALLOC_MODE_DETECT_LEAK
:
return
getline_detect_l
eak
(
lineptr
,
n
,
stream
,
file
,
line
);
return
taosGetlineDetectL
eak
(
lineptr
,
n
,
stream
,
file
,
line
);
}
return
taosGetlineImp
(
lineptr
,
n
,
stream
);
}
static
void
close_alloc_l
og
()
{
static
void
taosCloseAllocL
og
()
{
if
(
fpAllocLog
!=
NULL
)
{
if
(
fpAllocLog
!=
stdout
)
{
fclose
(
fpAllocLog
);
...
...
@@ -432,7 +432,7 @@ void taosSetAllocMode(int mode, const char* path, bool autoDump) {
if
(
path
==
NULL
||
path
[
0
]
==
0
)
{
fpAllocLog
=
stdout
;
}
else
if
((
fpAllocLog
=
fopen
(
path
,
"w"
))
!=
NULL
)
{
atexit
(
close_alloc_l
og
);
atexit
(
taosCloseAllocL
og
);
}
else
{
printf
(
"failed to open memory allocation log file '%s', errno=%d
\n
"
,
path
,
errno
);
return
;
...
...
@@ -446,10 +446,10 @@ void taosSetAllocMode(int mode, const char* path, bool autoDump) {
}
if
(
autoDump
&&
mode
==
TAOS_ALLOC_MODE_DETECT_LEAK
)
{
atexit
(
dump_memory_leak
);
atexit
(
taosDumpMemoryLeakImp
);
struct
sigaction
act
=
{
0
};
act
.
sa_handler
=
dump_memory_leak_on_s
ig
;
act
.
sa_handler
=
taosDumpMemoryLeakOnS
ig
;
sigaction
(
SIGFPE
,
&
act
,
NULL
);
sigaction
(
SIGSEGV
,
&
act
,
NULL
);
sigaction
(
SIGILL
,
&
act
,
NULL
);
...
...
@@ -457,8 +457,8 @@ void taosSetAllocMode(int mode, const char* path, bool autoDump) {
}
void
taosDumpMemoryLeak
()
{
dump_memory_leak
();
close_alloc_l
og
();
taosDumpMemoryLeakImp
();
taosCloseAllocL
og
();
}
#else // 'TAOS_MEM_CHECK' not defined
...
...
src/os/src/detail/osSysinfo.c
浏览文件 @
9e663ecd
...
...
@@ -61,7 +61,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
size_t
len
;
char
*
line
=
NULL
;
while
(
!
feof
(
fp
))
{
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
len
=
0
;
getline
(
&
line
,
&
len
,
fp
);
if
(
line
==
NULL
)
{
...
...
@@ -83,7 +83,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
&
memKB
);
*
memoryUsedMB
=
(
float
)((
double
)
memKB
/
1024
);
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
fclose
(
fp
);
return
true
;
}
...
...
@@ -107,7 +107,7 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
char
cpu
[
10
]
=
{
0
};
sscanf
(
line
,
"%s %"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
cpu
,
&
cpuInfo
->
user
,
&
cpuInfo
->
nice
,
&
cpuInfo
->
system
,
&
cpuInfo
->
idle
);
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
fclose
(
fp
);
return
true
;
}
...
...
@@ -136,7 +136,7 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
}
}
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
fclose
(
fp
);
return
true
;
}
...
...
@@ -377,7 +377,7 @@ static bool taosGetCardInfo(int64_t *bytes) {
*
bytes
+=
(
rbytes
+
tbytes
);
}
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
fclose
(
fp
);
return
true
;
...
...
@@ -432,7 +432,7 @@ static bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
int
readIndex
=
0
;
while
(
!
feof
(
fp
))
{
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
len
=
0
;
getline
(
&
line
,
&
len
,
fp
);
if
(
line
==
NULL
)
{
...
...
@@ -450,7 +450,7 @@ static bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
if
(
readIndex
>=
2
)
break
;
}
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
fclose
(
fp
);
if
(
readIndex
<
2
)
{
...
...
src/plugins/http/src/httpContext.c
浏览文件 @
9e663ecd
...
...
@@ -63,7 +63,7 @@ static void httpDestroyContext(void *data) {
pContext
->
parser
=
NULL
;
}
t
aosTF
ree
(
pContext
);
t
f
ree
(
pContext
);
}
bool
httpInitContexts
()
{
...
...
src/plugins/http/src/httpSystem.c
浏览文件 @
9e663ecd
...
...
@@ -107,7 +107,7 @@ void httpCleanUpSystem() {
httpCleanupResultQueue
();
pthread_mutex_destroy
(
&
tsHttpServer
.
serverMutex
);
t
aosTF
ree
(
tsHttpServer
.
pThreads
);
t
f
ree
(
tsHttpServer
.
pThreads
);
tsHttpServer
.
pThreads
=
NULL
;
tsHttpServer
.
status
=
HTTP_SERVER_CLOSED
;
...
...
src/query/src/qExecutor.c
浏览文件 @
9e663ecd
...
...
@@ -1019,7 +1019,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
bool
hasTimeWindow
=
false
;
STimeWindow
win
=
getActiveTimeWindow
(
pWindowResInfo
,
ts
,
pQuery
);
if
(
setWindowOutputBufByKey
(
pRuntimeEnv
,
pWindowResInfo
,
pDataBlockInfo
,
&
win
,
masterScan
,
&
hasTimeWindow
)
!=
TSDB_CODE_SUCCESS
)
{
t
aosTF
ree
(
sasArray
);
t
f
ree
(
sasArray
);
return
;
}
...
...
@@ -1081,10 +1081,10 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
continue
;
}
t
aosTF
ree
(
sasArray
[
i
].
data
);
t
f
ree
(
sasArray
[
i
].
data
);
}
t
aosTF
ree
(
sasArray
);
t
f
ree
(
sasArray
);
}
static
int32_t
setGroupResultOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupIndex
)
{
...
...
@@ -1410,7 +1410,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
continue
;
}
t
aosTF
ree
(
sasArray
[
i
].
data
);
t
f
ree
(
sasArray
[
i
].
data
);
}
free
(
sasArray
);
...
...
@@ -1596,7 +1596,7 @@ static int32_t setCtxTagColumnInfo(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
p
->
tagInfo
.
numOfTagCols
=
num
;
p
->
tagInfo
.
tagsLen
=
tagLen
;
}
else
{
t
aosTF
ree
(
pTagCtx
);
t
f
ree
(
pTagCtx
);
}
}
...
...
@@ -1706,7 +1706,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
return
TSDB_CODE_SUCCESS
;
_clean:
t
aosTF
ree
(
pRuntimeEnv
->
pCtx
);
t
f
ree
(
pRuntimeEnv
->
pCtx
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -1744,10 +1744,10 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
}
tVariantDestroy
(
&
pCtx
->
tag
);
t
aosTF
ree
(
pCtx
->
tagInfo
.
pTagCtxList
);
t
f
ree
(
pCtx
->
tagInfo
.
pTagCtxList
);
}
t
aosTF
ree
(
pRuntimeEnv
->
pCtx
);
t
f
ree
(
pRuntimeEnv
->
pCtx
);
}
pRuntimeEnv
->
pFillInfo
=
taosDestroyFillInfo
(
pRuntimeEnv
->
pFillInfo
);
...
...
@@ -1756,8 +1756,8 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
doFreeQueryHandle
(
pQInfo
);
pRuntimeEnv
->
pTSBuf
=
tsBufDestroy
(
pRuntimeEnv
->
pTSBuf
);
t
aosTF
ree
(
pRuntimeEnv
->
keyBuf
);
t
aosTF
ree
(
pRuntimeEnv
->
rowCellInfoOffset
);
t
f
ree
(
pRuntimeEnv
->
keyBuf
);
t
f
ree
(
pRuntimeEnv
->
rowCellInfoOffset
);
taosHashCleanup
(
pRuntimeEnv
->
pResultRowHashTable
);
pRuntimeEnv
->
pResultRowHashTable
=
NULL
;
...
...
@@ -2985,8 +2985,8 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
STableQueryInfo
**
pTableList
=
malloc
(
POINTER_BYTES
*
size
);
if
(
pTableList
==
NULL
||
posList
==
NULL
)
{
t
aosTF
ree
(
posList
);
t
aosTF
ree
(
pTableList
);
t
f
ree
(
posList
);
t
f
ree
(
pTableList
);
qError
(
"QInfo:%p failed alloc memory"
,
pQInfo
);
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
...
@@ -3010,12 +3010,12 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
// there is no data in current group
if
(
numOfTables
==
0
)
{
t
aosTF
ree
(
posList
);
t
aosTF
ree
(
pTableList
);
t
f
ree
(
posList
);
t
f
ree
(
pTableList
);
return
0
;
}
else
if
(
numOfTables
==
1
)
{
// no need to merge results since only one table in each group
t
aosTF
ree
(
posList
);
t
aosTF
ree
(
pTableList
);
t
f
ree
(
posList
);
t
f
ree
(
pTableList
);
SGroupResInfo
*
pGroupResInfo
=
&
pQInfo
->
groupResInfo
;
...
...
@@ -3045,9 +3045,9 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
qDebug
(
"QInfo:%p it is already killed, abort"
,
pQInfo
);
t
aosTF
ree
(
pTableList
);
t
aosTF
ree
(
posList
);
t
aosTF
ree
(
pTree
);
t
f
ree
(
pTableList
);
t
f
ree
(
posList
);
t
f
ree
(
pTree
);
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_TSC_QUERY_CANCELLED
);
}
...
...
@@ -3118,9 +3118,9 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
if
(
flushFromResultBuf
(
pRuntimeEnv
,
&
pQInfo
->
groupResInfo
)
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"QInfo:%p failed to flush data into temp file, abort query"
,
pQInfo
);
t
aosTF
ree
(
pTree
);
t
aosTF
ree
(
pTableList
);
t
aosTF
ree
(
posList
);
t
f
ree
(
pTree
);
t
f
ree
(
pTableList
);
t
f
ree
(
posList
);
return
-
1
;
}
}
...
...
@@ -3133,12 +3133,12 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
qDebug
(
"QInfo:%p result merge completed for group:%d, elapsed time:%"
PRId64
" ms"
,
pQInfo
,
pQInfo
->
groupIndex
,
endt
-
startt
);
t
aosTF
ree
(
pTableList
);
t
aosTF
ree
(
posList
);
t
aosTF
ree
(
pTree
);
t
f
ree
(
pTableList
);
t
f
ree
(
posList
);
t
f
ree
(
pTree
);
// t
aosTF
ree(pResultInfo);
// t
aosTF
ree(buf);
// t
f
ree(pResultInfo);
// t
f
ree(buf);
return
pQInfo
->
groupResInfo
.
numOfDataPages
;
}
...
...
@@ -5880,13 +5880,13 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
return
TSDB_CODE_SUCCESS
;
_cleanup:
t
aosTF
ree
(
*
pExpr
);
t
f
ree
(
*
pExpr
);
taosArrayDestroy
(
*
pTableIdList
);
*
pTableIdList
=
NULL
;
t
aosTF
ree
(
*
tbnameCond
);
t
aosTF
ree
(
*
groupbyCols
);
t
aosTF
ree
(
*
tagCols
);
t
aosTF
ree
(
*
tagCond
);
t
f
ree
(
*
tbnameCond
);
t
f
ree
(
*
groupbyCols
);
t
f
ree
(
*
tagCols
);
t
f
ree
(
*
tagCond
);
return
code
;
}
...
...
@@ -5937,7 +5937,7 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
code
=
buildAirthmeticExprFromMsg
(
&
pExprs
[
i
],
pQueryMsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
t
aosTF
ree
(
pExprs
);
t
f
ree
(
pExprs
);
return
code
;
}
...
...
@@ -5976,7 +5976,7 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
int32_t
param
=
(
int32_t
)
pExprs
[
i
].
base
.
arg
[
0
].
argValue
.
i64
;
if
(
getResultDataInfo
(
type
,
bytes
,
pExprs
[
i
].
base
.
functionId
,
param
,
&
pExprs
[
i
].
type
,
&
pExprs
[
i
].
bytes
,
&
pExprs
[
i
].
interBytes
,
0
,
isSuperTable
)
!=
TSDB_CODE_SUCCESS
)
{
t
aosTF
ree
(
pExprs
);
t
f
ree
(
pExprs
);
return
TSDB_CODE_QRY_INVALID_MSG
;
}
...
...
@@ -6352,7 +6352,7 @@ _cleanup_query:
free
(
pGroupbyExpr
);
}
t
aosTF
ree
(
pTagCols
);
t
f
ree
(
pTagCols
);
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SExprInfo
*
pExprInfo
=
&
pExprs
[
i
];
if
(
pExprInfo
->
pExpr
!=
NULL
)
{
...
...
@@ -6360,7 +6360,7 @@ _cleanup_query:
}
}
t
aosTF
ree
(
pExprs
);
t
f
ree
(
pExprs
);
_cleanup:
freeQInfo
(
pQInfo
);
...
...
@@ -6479,19 +6479,19 @@ static void freeQInfo(SQInfo *pQInfo) {
if
(
pQuery
!=
NULL
)
{
if
(
pQuery
->
sdata
!=
NULL
)
{
for
(
int32_t
col
=
0
;
col
<
pQuery
->
numOfOutput
;
++
col
)
{
t
aosTF
ree
(
pQuery
->
sdata
[
col
]);
t
f
ree
(
pQuery
->
sdata
[
col
]);
}
t
aosTF
ree
(
pQuery
->
sdata
);
t
f
ree
(
pQuery
->
sdata
);
}
if
(
pQuery
->
fillVal
!=
NULL
)
{
t
aosTF
ree
(
pQuery
->
fillVal
);
t
f
ree
(
pQuery
->
fillVal
);
}
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfFilterCols
;
++
i
)
{
SSingleColumnFilterInfo
*
pColFilter
=
&
pQuery
->
pFilterInfo
[
i
];
if
(
pColFilter
->
numOfFilters
>
0
)
{
t
aosTF
ree
(
pColFilter
->
pFilters
);
t
f
ree
(
pColFilter
->
pFilters
);
}
}
...
...
@@ -6504,31 +6504,31 @@ static void freeQInfo(SQInfo *pQInfo) {
}
}
t
aosTF
ree
(
pQuery
->
pSelectExpr
);
t
f
ree
(
pQuery
->
pSelectExpr
);
}
if
(
pQuery
->
pGroupbyExpr
!=
NULL
)
{
taosArrayDestroy
(
pQuery
->
pGroupbyExpr
->
columnInfo
);
t
aosTF
ree
(
pQuery
->
pGroupbyExpr
);
t
f
ree
(
pQuery
->
pGroupbyExpr
);
}
t
aosTF
ree
(
pQuery
->
tagColList
);
t
aosTF
ree
(
pQuery
->
pFilterInfo
);
t
f
ree
(
pQuery
->
tagColList
);
t
f
ree
(
pQuery
->
pFilterInfo
);
if
(
pQuery
->
colList
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfCols
;
i
++
)
{
SColumnInfo
*
column
=
pQuery
->
colList
+
i
;
freeColumnFilterInfo
(
column
->
filters
,
column
->
numOfFilters
);
}
t
aosTF
ree
(
pQuery
->
colList
);
t
f
ree
(
pQuery
->
colList
);
}
t
aosTF
ree
(
pQuery
);
t
f
ree
(
pQuery
);
}
doDestroyTableQueryInfo
(
&
pQInfo
->
tableqinfoGroupInfo
);
t
aosTF
ree
(
pQInfo
->
pBuf
);
t
f
ree
(
pQInfo
->
pBuf
);
tsdbDestroyTableGroup
(
&
pQInfo
->
tableGroupInfo
);
taosArrayDestroy
(
pQInfo
->
arrTableIdInfo
);
...
...
@@ -6536,7 +6536,7 @@ static void freeQInfo(SQInfo *pQInfo) {
qDebug
(
"QInfo:%p QInfo is freed"
,
pQInfo
);
t
aosTF
ree
(
pQInfo
);
t
f
ree
(
pQInfo
);
}
static
size_t
getResultSize
(
SQInfo
*
pQInfo
,
int64_t
*
numOfRows
)
{
...
...
@@ -7231,7 +7231,7 @@ void qCleanupQueryMgmt(void* pQMgmt) {
taosCacheCleanup
(
pqinfoPool
);
pthread_mutex_destroy
(
&
pQueryMgmt
->
lock
);
t
aosTF
ree
(
pQueryMgmt
);
t
f
ree
(
pQueryMgmt
);
qDebug
(
"vgId:%d queryMgmt cleanup completed"
,
vgId
);
}
...
...
src/query/src/qExtbuffer.c
浏览文件 @
9e663ecd
...
...
@@ -64,7 +64,7 @@ void* destoryExtMemBuffer(tExtMemBuffer *pMemBuffer) {
// release flush out info link
SExtFileInfo
*
pFileMeta
=
&
pMemBuffer
->
fileMeta
;
if
(
pFileMeta
->
flushoutData
.
nAllocSize
!=
0
&&
pFileMeta
->
flushoutData
.
pFlushoutInfo
!=
NULL
)
{
t
aosTF
ree
(
pFileMeta
->
flushoutData
.
pFlushoutInfo
);
t
f
ree
(
pFileMeta
->
flushoutData
.
pFlushoutInfo
);
}
// release all in-memory buffer pages
...
...
@@ -72,7 +72,7 @@ void* destoryExtMemBuffer(tExtMemBuffer *pMemBuffer) {
while
(
pFilePages
!=
NULL
)
{
tFilePagesItem
*
pTmp
=
pFilePages
;
pFilePages
=
pFilePages
->
pNext
;
t
aosTF
ree
(
pTmp
);
t
f
ree
(
pTmp
);
}
// close temp file
...
...
@@ -87,8 +87,8 @@ void* destoryExtMemBuffer(tExtMemBuffer *pMemBuffer) {
destroyColumnModel
(
pMemBuffer
->
pColumnModel
);
t
aosTF
ree
(
pMemBuffer
->
path
);
t
aosTF
ree
(
pMemBuffer
);
t
f
ree
(
pMemBuffer
->
path
);
t
f
ree
(
pMemBuffer
);
return
NULL
;
}
...
...
@@ -275,7 +275,7 @@ int32_t tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) {
tFilePagesItem
*
ptmp
=
first
;
first
=
first
->
pNext
;
t
aosTF
ree
(
ptmp
);
// release all data in memory buffer
t
f
ree
(
ptmp
);
// release all data in memory buffer
}
fflush
(
pMemBuffer
->
file
);
// flush to disk
...
...
@@ -300,7 +300,7 @@ void tExtMemBufferClear(tExtMemBuffer *pMemBuffer) {
while
(
first
!=
NULL
)
{
tFilePagesItem
*
ptmp
=
first
;
first
=
first
->
pNext
;
t
aosTF
ree
(
ptmp
);
t
f
ree
(
ptmp
);
}
pMemBuffer
->
fileMeta
.
numOfElemsInFile
=
0
;
...
...
@@ -802,7 +802,7 @@ void destroyColumnModel(SColumnModel *pModel) {
return
;
}
t
aosTF
ree
(
pModel
);
t
f
ree
(
pModel
);
}
static
void
printBinaryData
(
char
*
data
,
int32_t
len
)
{
...
...
@@ -1087,5 +1087,5 @@ void tOrderDescDestroy(tOrderDescriptor *pDesc) {
}
destroyColumnModel
(
pDesc
->
pColumnModel
);
t
aosTF
ree
(
pDesc
);
t
f
ree
(
pDesc
);
}
src/query/src/qFill.c
浏览文件 @
9e663ecd
...
...
@@ -96,18 +96,18 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
return
NULL
;
}
t
aosTF
ree
(
pFillInfo
->
prevValues
);
t
aosTF
ree
(
pFillInfo
->
nextValues
);
t
aosTF
ree
(
pFillInfo
->
pTags
);
t
f
ree
(
pFillInfo
->
prevValues
);
t
f
ree
(
pFillInfo
->
nextValues
);
t
f
ree
(
pFillInfo
->
pTags
);
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
t
aosTF
ree
(
pFillInfo
->
pData
[
i
]);
t
f
ree
(
pFillInfo
->
pData
[
i
]);
}
t
aosTF
ree
(
pFillInfo
->
pData
);
t
aosTF
ree
(
pFillInfo
->
pFillCol
);
t
f
ree
(
pFillInfo
->
pData
);
t
f
ree
(
pFillInfo
->
pFillCol
);
t
aosTF
ree
(
pFillInfo
);
t
f
ree
(
pFillInfo
);
return
NULL
;
}
...
...
@@ -496,7 +496,7 @@ int32_t generateDataBlockImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t nu
pFillInfo
->
numOfRows
=
0
;
/* the raw data block is exhausted, next value does not exists */
t
aosTF
ree
(
*
nextValues
);
t
f
ree
(
*
nextValues
);
}
pFillInfo
->
numOfTotal
+=
pFillInfo
->
numOfCurrent
;
...
...
src/query/src/qParserImpl.c
浏览文件 @
9e663ecd
...
...
@@ -571,7 +571,7 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
doDestroyQuerySql
(
pQuerySql
);
}
t
aosTF
ree
(
pClause
->
pClause
);
t
f
ree
(
pClause
->
pClause
);
}
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SStrToken
*
pStableName
,
...
...
@@ -641,12 +641,12 @@ void SQLInfoDestroy(SSqlInfo *pInfo) {
tFieldListDestroy
(
pCreateTableInfo
->
colInfo
.
pTagColumns
);
tVariantListDestroy
(
pCreateTableInfo
->
usingInfo
.
pTagVals
);
t
aosTF
ree
(
pInfo
->
pCreateTableInfo
);
t
f
ree
(
pInfo
->
pCreateTableInfo
);
}
else
if
(
pInfo
->
type
==
TSDB_SQL_ALTER_TABLE
)
{
tVariantListDestroy
(
pInfo
->
pAlterInfo
->
varList
);
tFieldListDestroy
(
pInfo
->
pAlterInfo
->
pAddColumns
);
t
aosTF
ree
(
pInfo
->
pAlterInfo
);
t
f
ree
(
pInfo
->
pAlterInfo
);
}
else
{
if
(
pInfo
->
pDCLInfo
!=
NULL
&&
pInfo
->
pDCLInfo
->
nAlloc
>
0
)
{
free
(
pInfo
->
pDCLInfo
->
a
);
...
...
@@ -656,7 +656,7 @@ void SQLInfoDestroy(SSqlInfo *pInfo) {
tVariantListDestroy
(
pInfo
->
pDCLInfo
->
dbOpt
.
keep
);
}
t
aosTF
ree
(
pInfo
->
pDCLInfo
);
t
f
ree
(
pInfo
->
pDCLInfo
);
}
}
...
...
src/query/src/qPercentile.c
浏览文件 @
9e663ecd
...
...
@@ -361,8 +361,8 @@ void tMemBucketDestroy(tMemBucket *pBucket) {
}
destroyResultBuf
(
pBucket
->
pBuffer
);
t
aosTF
ree
(
pBucket
->
pSlots
);
t
aosTF
ree
(
pBucket
);
t
f
ree
(
pBucket
->
pSlots
);
t
f
ree
(
pBucket
);
}
void
tMemBucketUpdateBoundingBox
(
MinMaxEntry
*
r
,
const
char
*
data
,
int32_t
dataType
)
{
...
...
@@ -680,7 +680,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
}
double
val
=
(
1
-
fraction
)
*
td
+
fraction
*
nd
;
t
aosTF
ree
(
buffer
);
t
f
ree
(
buffer
);
return
val
;
}
else
{
// incur a second round bucket split
...
...
src/query/src/qResultbuf.c
浏览文件 @
9e663ecd
...
...
@@ -267,7 +267,7 @@ static char* evicOneDataPage(SDiskbasedResultBuf* pResultBuf) {
assert
(
d
->
pn
==
pn
);
d
->
pn
=
NULL
;
t
aosTF
ree
(
pn
);
t
f
ree
(
pn
);
bufPage
=
flushPageToDisk
(
pResultBuf
,
d
);
}
...
...
@@ -418,7 +418,7 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
}
unlink
(
pResultBuf
->
path
);
t
aosTF
ree
(
pResultBuf
->
path
);
t
f
ree
(
pResultBuf
->
path
);
SHashMutableIterator
*
iter
=
taosHashCreateIter
(
pResultBuf
->
groupSet
);
while
(
taosHashIterNext
(
iter
))
{
...
...
@@ -426,8 +426,8 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
size_t
n
=
taosArrayGetSize
(
*
p
);
for
(
int32_t
i
=
0
;
i
<
n
;
++
i
)
{
SPageInfo
*
pi
=
taosArrayGetP
(
*
p
,
i
);
t
aosTF
ree
(
pi
->
pData
);
t
aosTF
ree
(
pi
);
t
f
ree
(
pi
->
pData
);
t
f
ree
(
pi
);
}
taosArrayDestroy
(
*
p
);
...
...
@@ -440,8 +440,8 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
taosHashCleanup
(
pResultBuf
->
groupSet
);
taosHashCleanup
(
pResultBuf
->
all
);
t
aosTF
ree
(
pResultBuf
->
assistBuf
);
t
aosTF
ree
(
pResultBuf
);
t
f
ree
(
pResultBuf
->
assistBuf
);
t
f
ree
(
pResultBuf
);
}
SPageInfo
*
getLastPageInfo
(
SIDList
pList
)
{
...
...
src/query/src/qTsbuf.c
浏览文件 @
9e663ecd
...
...
@@ -142,11 +142,11 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
return
NULL
;
}
t
aosTF
ree
(
pTSBuf
->
assistBuf
);
t
aosTF
ree
(
pTSBuf
->
tsData
.
rawBuf
);
t
f
ree
(
pTSBuf
->
assistBuf
);
t
f
ree
(
pTSBuf
->
tsData
.
rawBuf
);
t
aosTF
ree
(
pTSBuf
->
pData
);
t
aosTF
ree
(
pTSBuf
->
block
.
payload
);
t
f
ree
(
pTSBuf
->
pData
);
t
f
ree
(
pTSBuf
->
block
.
payload
);
fclose
(
pTSBuf
->
f
);
...
...
src/query/src/qUtil.c
浏览文件 @
9e663ecd
...
...
@@ -57,7 +57,7 @@ void cleanupTimeWindowInfo(SWindowResInfo *pWindowResInfo) {
return
;
}
t
aosTF
ree
(
pWindowResInfo
->
pResult
);
t
f
ree
(
pWindowResInfo
->
pResult
);
}
void
resetTimeWindowInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SWindowResInfo
*
pWindowResInfo
)
{
...
...
@@ -358,11 +358,11 @@ void* destroyResultRowPool(SResultRowPool* p) {
size_t
size
=
taosArrayGetSize
(
p
->
pData
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
void
**
ptr
=
taosArrayGet
(
p
->
pData
,
i
);
t
aosTF
ree
(
*
ptr
);
t
f
ree
(
*
ptr
);
}
taosArrayDestroy
(
p
->
pData
);
t
aosTF
ree
(
p
);
t
f
ree
(
p
);
return
NULL
;
}
src/rpc/src/rpcCache.c
浏览文件 @
9e663ecd
...
...
@@ -101,9 +101,9 @@ void rpcCloseConnCache(void *handle) {
if
(
pCache
->
connHashMemPool
)
taosMemPoolCleanUp
(
pCache
->
connHashMemPool
);
t
aosTF
ree
(
pCache
->
connHashList
);
t
aosTF
ree
(
pCache
->
count
);
t
aosTF
ree
(
pCache
->
lockedBy
);
t
f
ree
(
pCache
->
connHashList
);
t
f
ree
(
pCache
->
count
);
t
f
ree
(
pCache
->
lockedBy
);
pthread_mutex_unlock
(
&
pCache
->
mutex
);
...
...
src/rpc/src/rpcMain.c
浏览文件 @
9e663ecd
...
...
@@ -1620,10 +1620,10 @@ static void rpcDecRef(SRpcInfo *pRpc)
taosTmrCleanUp
(
pRpc
->
tmrCtrl
);
taosIdPoolCleanUp
(
pRpc
->
idPool
);
t
aosTF
ree
(
pRpc
->
connList
);
t
f
ree
(
pRpc
->
connList
);
pthread_mutex_destroy
(
&
pRpc
->
mutex
);
tDebug
(
"%s rpc resources are released"
,
pRpc
->
label
);
t
aosTF
ree
(
pRpc
);
t
f
ree
(
pRpc
);
atomic_sub_fetch_32
(
&
tsRpcNum
,
1
);
}
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
9e663ecd
...
...
@@ -236,8 +236,8 @@ void taosCleanUpTcpServer(void *handle) {
tDebug
(
"%s TCP server is cleaned up"
,
pServerObj
->
label
);
t
aosTF
ree
(
pServerObj
->
pThreadObj
);
t
aosTF
ree
(
pServerObj
);
t
f
ree
(
pServerObj
->
pThreadObj
);
t
f
ree
(
pServerObj
);
}
static
void
*
taosAcceptTcpConnection
(
void
*
arg
)
{
...
...
@@ -535,7 +535,7 @@ static void *taosProcessTcpData(void *param) {
pthread_mutex_destroy
(
&
(
pThreadObj
->
mutex
));
tDebug
(
"%s TCP thread exits ..."
,
pThreadObj
->
label
);
t
aosTF
ree
(
pThreadObj
);
t
f
ree
(
pThreadObj
);
return
NULL
;
}
...
...
@@ -556,7 +556,7 @@ static SFdObj *taosMallocFdObj(SThreadObj *pThreadObj, SOCKET fd) {
event
.
events
=
EPOLLIN
|
EPOLLRDHUP
;
event
.
data
.
ptr
=
pFdObj
;
if
(
epoll_ctl
(
pThreadObj
->
pollFd
,
EPOLL_CTL_ADD
,
fd
,
&
event
)
<
0
)
{
t
aosTF
ree
(
pFdObj
);
t
f
ree
(
pFdObj
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
...
...
@@ -609,5 +609,5 @@ static void taosFreeFdObj(SFdObj *pFdObj) {
tDebug
(
"%s %p TCP connection is closed, FD:%p numOfFds:%d"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
pFdObj
,
pThreadObj
->
numOfFds
);
t
aosTF
ree
(
pFdObj
);
t
f
ree
(
pFdObj
);
}
src/rpc/src/rpcUdp.c
浏览文件 @
9e663ecd
...
...
@@ -147,7 +147,7 @@ void taosStopUdpConnection(void *handle) {
if
(
taosCheckPthreadValid
(
pConn
->
thread
))
{
pthread_join
(
pConn
->
thread
,
NULL
);
}
t
aosTF
ree
(
pConn
->
buffer
);
t
f
ree
(
pConn
->
buffer
);
// tTrace("%s UDP thread is closed, index:%d", pConn->label, i);
}
...
...
@@ -166,7 +166,7 @@ void taosCleanUpUdpConnection(void *handle) {
}
tDebug
(
"%s UDP is cleaned up"
,
pSet
->
label
);
t
aosTF
ree
(
pSet
);
t
f
ree
(
pSet
);
}
void
*
taosOpenUdpConnection
(
void
*
shandle
,
void
*
thandle
,
uint32_t
ip
,
uint16_t
port
)
{
...
...
src/sync/inc/taosTcpPool.h
浏览文件 @
9e663ecd
...
...
@@ -20,23 +20,23 @@
extern
"C"
{
#endif
typedef
void
*
ttpool_h
;
typedef
void
*
tthread_h
;
typedef
void
*
ttpool_h
;
typedef
void
*
tthread_h
;
typedef
struct
{
int
numOfThreads
;
int
32_t
numOfThreads
;
uint32_t
serverIp
;
int16_t
port
;
int
bufferSize
;
void
(
*
processBrokenLink
)(
void
*
ahandle
);
int
(
*
processIncomingMsg
)(
void
*
ahandle
,
void
*
buffer
);
void
(
*
processIncomingConn
)(
in
t
fd
,
uint32_t
ip
);
int
32_t
bufferSize
;
void
(
*
processBrokenLink
)(
void
*
ahandle
);
int
32_t
(
*
processIncomingMsg
)(
void
*
ahandle
,
void
*
buffer
);
void
(
*
processIncomingConn
)(
int32_
t
fd
,
uint32_t
ip
);
}
SPoolInfo
;
ttpool_h
taosOpenTcpThreadPool
(
SPoolInfo
*
pInfo
);
void
taosCloseTcpThreadPool
(
ttpool_h
);
void
*
taosAllocateTcpConn
(
void
*
,
void
*
ahandle
,
in
t
connFd
);
void
taosFreeTcpConn
(
void
*
);
ttpool_h
taosOpenTcpThreadPool
(
SPoolInfo
*
pInfo
);
void
taosCloseTcpThreadPool
(
ttpool_h
);
void
*
taosAllocateTcpConn
(
void
*
,
void
*
ahandle
,
int32_
t
connFd
);
void
taosFreeTcpConn
(
void
*
);
#ifdef __cplusplus
}
...
...
src/sync/src/syncMain.c
浏览文件 @
9e663ecd
...
...
@@ -437,9 +437,9 @@ static void syncFreeNode(void *param) {
SSyncNode
*
pNode
=
param
;
pthread_mutex_destroy
(
&
pNode
->
mutex
);
t
aosTF
ree
(
pNode
->
pRecv
);
t
aosTF
ree
(
pNode
->
pSyncFwds
);
t
aosTF
ree
(
pNode
);
t
f
ree
(
pNode
->
pRecv
);
t
f
ree
(
pNode
->
pSyncFwds
);
t
f
ree
(
pNode
);
}
void
syncAddPeerRef
(
SSyncPeer
*
pPeer
)
{
atomic_add_fetch_8
(
&
pPeer
->
refCount
,
1
);
}
...
...
@@ -449,8 +449,8 @@ int syncDecPeerRef(SSyncPeer *pPeer) {
taosReleaseRef
(
tsSyncRefId
,
pPeer
->
pSyncNode
->
rid
);
sDebug
(
"%s, resource is freed"
,
pPeer
->
id
);
t
aosTF
ree
(
pPeer
->
watchFd
);
t
aosTF
ree
(
pPeer
);
t
f
ree
(
pPeer
->
watchFd
);
t
f
ree
(
pPeer
);
return
0
;
}
...
...
src/sync/src/syncRestore.c
浏览文件 @
9e663ecd
...
...
@@ -225,10 +225,10 @@ int syncSaveIntoBuffer(SSyncPeer *pPeer, SWalHead *pHead) {
static
void
syncCloseRecvBuffer
(
SSyncNode
*
pNode
)
{
if
(
pNode
->
pRecv
)
{
t
aosTF
ree
(
pNode
->
pRecv
->
buffer
);
t
f
ree
(
pNode
->
pRecv
->
buffer
);
}
t
aosTF
ree
(
pNode
->
pRecv
);
t
f
ree
(
pNode
->
pRecv
);
}
static
int
syncOpenRecvBuffer
(
SSyncNode
*
pNode
)
{
...
...
src/sync/src/taosTcpPool.c
浏览文件 @
9e663ecd
...
...
@@ -108,7 +108,7 @@ void taosCloseTcpThreadPool(void *param) {
sDebug
(
"%p TCP pool is closed"
,
pPool
);
t
aosTF
ree
(
pPool
->
pThread
);
t
f
ree
(
pPool
->
pThread
);
tfree
(
pPool
);
}
...
...
src/sync/src/tarbitrator.c
浏览文件 @
9e663ecd
...
...
@@ -131,7 +131,7 @@ static void arbProcessIncommingConnection(int connFd, uint32_t sourceIp) {
snprintf
(
pNode
->
id
,
sizeof
(
pNode
->
id
),
"vgId:%d peer:%s:%d"
,
firstPkt
.
sourceId
,
firstPkt
.
fqdn
,
firstPkt
.
port
);
if
(
firstPkt
.
syncHead
.
vgId
)
{
sDebug
(
"%s, vgId in head is not zero, close the connection"
,
pNode
->
id
);
t
aosTF
ree
(
pNode
);
t
f
ree
(
pNode
);
taosCloseSocket
(
connFd
);
return
;
}
...
...
@@ -147,7 +147,7 @@ static void arbProcessBrokenLink(void *param) {
SNodeConn
*
pNode
=
param
;
sDebug
(
"%s, TCP link is broken(%s), close connection"
,
pNode
->
id
,
strerror
(
errno
));
t
aosTF
ree
(
pNode
);
t
f
ree
(
pNode
);
}
static
int
arbProcessPeerMsg
(
void
*
param
,
void
*
buffer
)
{
...
...
src/tsdb/src/tsdbBuffer.c
浏览文件 @
9e663ecd
...
...
@@ -157,4 +157,4 @@ _err:
return
NULL
;
}
static
void
tsdbFreeBufBlock
(
STsdbBufBlock
*
pBufBlock
)
{
taosTFree
(
pBufBlock
);
}
\ No newline at end of file
static
void
tsdbFreeBufBlock
(
STsdbBufBlock
*
pBufBlock
)
{
tfree
(
pBufBlock
);
}
\ No newline at end of file
src/tsdb/src/tsdbFile.c
浏览文件 @
9e663ecd
...
...
@@ -65,7 +65,7 @@ _err:
void
tsdbFreeFileH
(
STsdbFileH
*
pFileH
)
{
if
(
pFileH
)
{
pthread_rwlock_destroy
(
&
pFileH
->
fhlock
);
t
aosTF
ree
(
pFileH
->
pFGroup
);
t
f
ree
(
pFileH
->
pFGroup
);
free
(
pFileH
);
}
}
...
...
@@ -199,7 +199,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
regfree
(
&
regex1
);
regfree
(
&
regex2
);
t
aosTF
ree
(
tDataDir
);
t
f
ree
(
tDataDir
);
closedir
(
dir
);
return
0
;
...
...
@@ -209,7 +209,7 @@ _err:
regfree
(
&
regex1
);
regfree
(
&
regex2
);
t
aosTF
ree
(
tDataDir
);
t
f
ree
(
tDataDir
);
if
(
dir
!=
NULL
)
closedir
(
dir
);
tsdbCloseFileH
(
pRepo
);
return
-
1
;
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
9e663ecd
...
...
@@ -228,7 +228,7 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
int
prefixLen
=
(
int
)
strlen
(
prefix
);
if
(
name
[
0
]
==
0
)
{
// get the file from index or after, but not larger than eindex
t
aosTF
ree
(
sdup
);
t
f
ree
(
sdup
);
int
fid
=
(
*
index
)
/
TSDB_FILE_TYPE_MAX
;
if
(
pFileH
->
nFGroups
==
0
||
fid
>
pFileH
->
pFGroup
[
pFileH
->
nFGroups
-
1
].
fileId
)
{
...
...
@@ -260,8 +260,8 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
fname
=
malloc
(
prefixLen
+
strlen
(
name
)
+
2
);
sprintf
(
fname
,
"%s/%s"
,
prefix
,
name
);
if
(
access
(
fname
,
F_OK
)
!=
0
)
{
t
aosF
ree
(
fname
);
t
aosF
ree
(
sdup
);
t
f
ree
(
fname
);
t
f
ree
(
sdup
);
return
0
;
}
if
(
*
index
==
TSDB_META_FILE_INDEX
)
{
// get meta file
...
...
@@ -269,20 +269,20 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
}
else
{
tsdbGetFileInfoImpl
(
fname
,
&
magic
,
size
);
}
t
aosF
ree
(
fname
);
t
aosF
ree
(
sdup
);
t
f
ree
(
fname
);
t
f
ree
(
sdup
);
return
magic
;
}
if
(
stat
(
fname
,
&
fState
)
<
0
)
{
t
aosTF
ree
(
fname
);
t
f
ree
(
fname
);
return
0
;
}
*
size
=
fState
.
st_size
;
// magic = *size;
t
aosTF
ree
(
fname
);
t
f
ree
(
fname
);
return
magic
;
}
...
...
@@ -600,7 +600,7 @@ static int32_t tsdbSaveConfig(char *rootDir, STsdbCfg *pCfg) {
return
0
;
_err:
t
aosTF
ree
(
fname
);
t
f
ree
(
fname
);
if
(
fd
>=
0
)
close
(
fd
);
return
-
1
;
}
...
...
@@ -637,13 +637,13 @@ static int tsdbLoadConfig(char *rootDir, STsdbCfg *pCfg) {
tsdbDecodeCfg
(
buf
,
pCfg
);
t
aosTF
ree
(
fname
);
t
f
ree
(
fname
);
close
(
fd
);
return
0
;
_err:
t
aosTF
ree
(
fname
);
t
f
ree
(
fname
);
if
(
fd
>=
0
)
close
(
fd
);
return
-
1
;
}
...
...
@@ -718,7 +718,7 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) {
tsdbFreeMeta
(
pRepo
->
tsdbMeta
);
// tsdbFreeMemTable(pRepo->mem);
// tsdbFreeMemTable(pRepo->imem);
t
aosTF
ree
(
pRepo
->
rootDir
);
t
f
ree
(
pRepo
->
rootDir
);
pthread_mutex_destroy
(
&
pRepo
->
mutex
);
free
(
pRepo
);
}
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
9e663ecd
...
...
@@ -488,7 +488,7 @@ static void tsdbFreeMemTable(SMemTable* pMemTable) {
tdListFree
(
pMemTable
->
extraBuffList
);
tdListFree
(
pMemTable
->
bufBlockList
);
tdListFree
(
pMemTable
->
actList
);
t
aosTF
ree
(
pMemTable
->
tData
);
t
f
ree
(
pMemTable
->
tData
);
free
(
pMemTable
);
}
}
...
...
@@ -746,7 +746,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
goto
_err
;
}
t
aosTF
ree
(
dataDir
);
t
f
ree
(
dataDir
);
tsdbCloseHelperFile
(
pHelper
,
0
,
pGroup
);
pthread_rwlock_wrlock
(
&
(
pFileH
->
fhlock
));
...
...
@@ -768,7 +768,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
return
0
;
_err:
t
aosTF
ree
(
dataDir
);
t
f
ree
(
dataDir
);
tsdbCloseHelperFile
(
pHelper
,
1
,
NULL
);
return
-
1
;
}
...
...
@@ -843,7 +843,7 @@ static int tsdbAdjustMemMaxTables(SMemTable *pMemTable, int maxTables) {
pMemTable
->
tData
=
pTableData
;
taosWUnLockLatch
(
&
(
pMemTable
->
latch
));
t
aosTF
ree
(
tData
);
t
f
ree
(
tData
);
return
0
;
}
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
9e663ecd
...
...
@@ -192,7 +192,7 @@ int tsdbDropTable(TSDB_REPO_T *repo, STableId tableId) {
return
0
;
_err:
t
aosTF
ree
(
tbname
);
t
f
ree
(
tbname
);
return
-
1
;
}
...
...
@@ -462,7 +462,7 @@ void tsdbFreeMeta(STsdbMeta *pMeta) {
if
(
pMeta
)
{
taosHashCleanup
(
pMeta
->
uidMap
);
tdListFree
(
pMeta
->
superList
);
t
aosTF
ree
(
pMeta
->
tables
);
t
f
ree
(
pMeta
->
tables
);
pthread_rwlock_destroy
(
&
pMeta
->
rwLock
);
free
(
pMeta
);
}
...
...
@@ -486,11 +486,11 @@ int tsdbOpenMeta(STsdbRepo *pRepo) {
}
tsdbDebug
(
"vgId:%d open TSDB meta succeed"
,
REPO_ID
(
pRepo
));
t
aosTF
ree
(
fname
);
t
f
ree
(
fname
);
return
0
;
_err:
t
aosTF
ree
(
fname
);
t
f
ree
(
fname
);
return
-
1
;
}
...
...
@@ -761,7 +761,7 @@ static void tsdbFreeTable(STable *pTable) {
if
(
pTable
->
name
!=
NULL
)
tsdbTrace
(
"table %s tid %d uid %"
PRIu64
" is freed"
,
TABLE_CHAR_NAME
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_UID
(
pTable
));
t
aosTF
ree
(
TABLE_NAME
(
pTable
));
t
f
ree
(
TABLE_NAME
(
pTable
));
if
(
TABLE_TYPE
(
pTable
)
!=
TSDB_CHILD_TABLE
)
{
for
(
int
i
=
0
;
i
<
TSDB_MAX_TABLE_SCHEMAS
;
i
++
)
{
tdFreeSchema
(
pTable
->
schema
[
i
]);
...
...
@@ -775,7 +775,7 @@ static void tsdbFreeTable(STable *pTable) {
kvRowFree
(
pTable
->
tagVal
);
tSkipListDestroy
(
pTable
->
pIndex
);
t
aosTF
ree
(
pTable
->
sql
);
t
f
ree
(
pTable
->
sql
);
free
(
pTable
);
}
}
...
...
@@ -1066,9 +1066,9 @@ void tsdbClearTableCfg(STableCfg *config) {
if
(
config
->
schema
)
tdFreeSchema
(
config
->
schema
);
if
(
config
->
tagSchema
)
tdFreeSchema
(
config
->
tagSchema
);
if
(
config
->
tagValues
)
kvRowFree
(
config
->
tagValues
);
t
aosTF
ree
(
config
->
name
);
t
aosTF
ree
(
config
->
sname
);
t
aosTF
ree
(
config
->
sql
);
t
f
ree
(
config
->
name
);
t
f
ree
(
config
->
sname
);
t
f
ree
(
config
->
sql
);
free
(
config
);
}
}
...
...
@@ -1290,7 +1290,7 @@ static int tsdbAdjustMetaTables(STsdbRepo *pRepo, int tid) {
STable
**
tTables
=
pMeta
->
tables
;
pMeta
->
tables
=
tables
;
t
aosTF
ree
(
tTables
);
t
f
ree
(
tTables
);
tsdbDebug
(
"vgId:%d tsdb meta maxTables is adjusted as %d"
,
REPO_ID
(
pRepo
),
maxTables
);
return
0
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
9e663ecd
...
...
@@ -1544,15 +1544,15 @@ int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order) {
}
static
void
cleanBlockOrderSupporter
(
SBlockOrderSupporter
*
pSupporter
,
int32_t
numOfTables
)
{
t
aosTF
ree
(
pSupporter
->
numOfBlocksPerTable
);
t
aosTF
ree
(
pSupporter
->
blockIndexArray
);
t
f
ree
(
pSupporter
->
numOfBlocksPerTable
);
t
f
ree
(
pSupporter
->
blockIndexArray
);
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableBlockInfo
*
pBlockInfo
=
pSupporter
->
pDataBlockInfo
[
i
];
t
aosTF
ree
(
pBlockInfo
);
t
f
ree
(
pBlockInfo
);
}
t
aosTF
ree
(
pSupporter
->
pDataBlockInfo
);
t
f
ree
(
pSupporter
->
pDataBlockInfo
);
}
static
int32_t
dataBlockOrderCompar
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
)
{
...
...
@@ -1970,7 +1970,7 @@ static void destroyHelper(void* param) {
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
if
(
pInfo
->
optr
!=
TSDB_RELATION_IN
)
{
t
aosTF
ree
(
pInfo
->
q
);
t
f
ree
(
pInfo
->
q
);
}
free
(
param
);
...
...
@@ -2035,7 +2035,7 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
STsdbQueryHandle
*
pSecQueryHandle
=
tsdbQueryTablesImpl
(
pQueryHandle
->
pTsdb
,
&
cond
,
pQueryHandle
->
qinfo
,
pQueryHandle
->
pMemRef
);
t
aosTF
ree
(
cond
.
colList
);
t
f
ree
(
cond
.
colList
);
pSecQueryHandle
->
pTableCheckInfo
=
createCheckInfoFromCheckInfo
(
pQueryHandle
->
pTableCheckInfo
,
pSecQueryHandle
->
window
.
skey
);
if
(
pSecQueryHandle
->
pTableCheckInfo
==
NULL
)
{
...
...
@@ -2750,7 +2750,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
STableCheckInfo
*
pTableCheckInfo
=
taosArrayGet
(
pQueryHandle
->
pTableCheckInfo
,
i
);
destroyTableMemIterator
(
pTableCheckInfo
);
t
aosTF
ree
(
pTableCheckInfo
->
pCompInfo
);
t
f
ree
(
pTableCheckInfo
->
pCompInfo
);
}
taosArrayDestroy
(
pQueryHandle
->
pTableCheckInfo
);
}
...
...
@@ -2759,14 +2759,14 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
size_t
cols
=
taosArrayGetSize
(
pQueryHandle
->
pColumns
);
for
(
int32_t
i
=
0
;
i
<
cols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
t
aosTF
ree
(
pColInfo
->
pData
);
t
f
ree
(
pColInfo
->
pData
);
}
taosArrayDestroy
(
pQueryHandle
->
pColumns
);
}
taosArrayDestroy
(
pQueryHandle
->
defaultLoadColumn
);
t
aosTF
ree
(
pQueryHandle
->
pDataBlockInfo
);
t
aosTF
ree
(
pQueryHandle
->
statis
);
t
f
ree
(
pQueryHandle
->
pDataBlockInfo
);
t
f
ree
(
pQueryHandle
->
statis
);
// todo check error
tsdbMayUnTakeMemSnapshot
(
pQueryHandle
);
...
...
@@ -2780,7 +2780,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
tsdbDebug
(
"%p :io-cost summary: statis-info:%"
PRId64
" us, datablock:%"
PRId64
" us, check data:%"
PRId64
" us, %p"
,
pQueryHandle
,
pCost
->
statisInfoLoadTime
,
pCost
->
blockLoadTime
,
pCost
->
checkForNextTime
,
pQueryHandle
->
qinfo
);
t
aosTF
ree
(
pQueryHandle
);
t
f
ree
(
pQueryHandle
);
}
void
tsdbDestroyTableGroup
(
STableGroupInfo
*
pGroupList
)
{
...
...
src/tsdb/tests/tsdbTests.cpp
浏览文件 @
9e663ecd
...
...
@@ -80,7 +80,7 @@ static int insertData(SInsertInfo *pInfo) {
pMsg
->
numOfBlocks
=
htonl
(
pMsg
->
numOfBlocks
);
if
(
tsdbInsertData
(
pInfo
->
pRepo
,
pMsg
,
NULL
)
<
0
)
{
t
aosTF
ree
(
pMsg
);
t
f
ree
(
pMsg
);
return
-
1
;
}
}
...
...
@@ -88,7 +88,7 @@ static int insertData(SInsertInfo *pInfo) {
double
etime
=
getCurTime
();
printf
(
"Spent %f seconds to write %d records
\n
"
,
etime
-
stime
,
pInfo
->
totalRows
);
t
aosTF
ree
(
pMsg
);
t
f
ree
(
pMsg
);
return
0
;
}
...
...
src/util/src/hash.c
浏览文件 @
9e663ecd
...
...
@@ -22,7 +22,7 @@
#define DO_FREE_HASH_NODE(_n) \
do { \
t
aosTF
ree(_n); \
t
f
ree(_n); \
} while (0)
#define FREE_HASH_NODE(_h, _n) \
...
...
@@ -522,7 +522,7 @@ void taosHashCleanup(SHashObj *pHashObj) {
size_t
memBlock
=
taosArrayGetSize
(
pHashObj
->
pMemBlock
);
for
(
int32_t
i
=
0
;
i
<
memBlock
;
++
i
)
{
void
*
p
=
taosArrayGetP
(
pHashObj
->
pMemBlock
,
i
);
t
aosTF
ree
(
p
);
t
f
ree
(
p
);
}
taosArrayDestroy
(
pHashObj
->
pMemBlock
);
...
...
src/util/src/talgo.c
浏览文件 @
9e663ecd
...
...
@@ -153,7 +153,7 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const
void
taosqsort
(
void
*
src
,
size_t
numOfElem
,
size_t
size
,
const
void
*
param
,
__ext_compar_fn_t
comparFn
)
{
char
*
buf
=
calloc
(
1
,
size
);
// prepare the swap buffer
tqsortImpl
(
src
,
0
,
(
int32_t
)
numOfElem
-
1
,
(
int32_t
)
size
,
param
,
comparFn
,
buf
);
t
aosTF
ree
(
buf
);
t
f
ree
(
buf
);
}
void
*
taosbsearch
(
const
void
*
key
,
const
void
*
base
,
size_t
nmemb
,
size_t
size
,
__compar_fn_t
compar
,
int
flags
)
{
...
...
src/util/src/tcache.c
浏览文件 @
9e663ecd
...
...
@@ -228,7 +228,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
pCacheObj
->
freeFp
(
p
->
data
);
}
t
aosTF
ree
(
p
);
t
f
ree
(
p
);
}
else
{
taosAddToTrashcan
(
pCacheObj
,
p
);
uDebug
(
"cache:%s, key:%p, %p exist in cache, updated old:%p"
,
pCacheObj
->
name
,
key
,
pNode1
->
data
,
p
->
data
);
...
...
@@ -614,7 +614,7 @@ void doCleanupDataCache(SCacheObj *pCacheObj) {
__cache_lock_destroy
(
pCacheObj
);
t
aosTF
ree
(
pCacheObj
->
name
);
t
f
ree
(
pCacheObj
->
name
);
memset
(
pCacheObj
,
0
,
sizeof
(
SCacheObj
));
free
(
pCacheObj
);
}
...
...
src/util/src/tconfig.c
浏览文件 @
9e663ecd
...
...
@@ -288,7 +288,7 @@ void taosReadGlobalLogCfg() {
option
=
value
=
NULL
;
olen
=
vlen
=
0
;
t
aosG
etline
(
&
line
,
&
len
,
fp
);
t
g
etline
(
&
line
,
&
len
,
fp
);
line
[
len
-
1
]
=
0
;
paGetToken
(
line
,
&
option
,
&
olen
);
...
...
@@ -302,7 +302,7 @@ void taosReadGlobalLogCfg() {
taosReadLogOption
(
option
,
value
);
}
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
fclose
(
fp
);
}
...
...
@@ -334,7 +334,7 @@ bool taosReadGlobalCfg() {
option
=
value
=
NULL
;
olen
=
vlen
=
0
;
t
aosG
etline
(
&
line
,
&
len
,
fp
);
t
g
etline
(
&
line
,
&
len
,
fp
);
line
[
len
-
1
]
=
0
;
paGetToken
(
line
,
&
option
,
&
olen
);
...
...
@@ -354,7 +354,7 @@ bool taosReadGlobalCfg() {
fclose
(
fp
);
t
aosTF
ree
(
line
);
t
f
ree
(
line
);
if
(
debugFlag
&
DEBUG_TRACE
||
debugFlag
&
DEBUG_DEBUG
||
debugFlag
&
DEBUG_DUMP
)
{
taosSetAllDebugFlag
();
...
...
src/util/src/tkvstore.c
浏览文件 @
9e663ecd
...
...
@@ -475,9 +475,9 @@ _err:
static
void
tdFreeKVStore
(
SKVStore
*
pStore
)
{
if
(
pStore
)
{
t
aosTF
ree
(
pStore
->
fname
);
t
aosTF
ree
(
pStore
->
fsnap
);
t
aosTF
ree
(
pStore
->
fnew
);
t
f
ree
(
pStore
->
fname
);
t
f
ree
(
pStore
->
fsnap
);
t
f
ree
(
pStore
->
fnew
);
taosHashCleanup
(
pStore
->
map
);
free
(
pStore
);
}
...
...
@@ -616,11 +616,11 @@ static int tdRestoreKVStore(SKVStore *pStore) {
if
(
pStore
->
aFunc
)
(
*
pStore
->
aFunc
)(
pStore
->
appH
);
taosHashDestroyIter
(
pIter
);
t
aosTF
ree
(
buf
);
t
f
ree
(
buf
);
return
0
;
_err:
taosHashDestroyIter
(
pIter
);
t
aosTF
ree
(
buf
);
t
f
ree
(
buf
);
return
-
1
;
}
src/util/src/tlog.c
浏览文件 @
9e663ecd
...
...
@@ -512,8 +512,8 @@ static SLogBuff *taosLogBuffNew(int32_t bufSize) {
return
tLogBuff
;
_err:
t
aosTF
ree
(
LOG_BUF_BUFFER
(
tLogBuff
));
t
aosTF
ree
(
tLogBuff
);
t
f
ree
(
LOG_BUF_BUFFER
(
tLogBuff
));
t
f
ree
(
tLogBuff
);
return
NULL
;
}
...
...
@@ -522,7 +522,7 @@ static void taosLogBuffDestroy(SLogBuff *tLogBuff) {
tsem_destroy(&(tLogBuff->buffNotEmpty));
pthread_mutex_destroy(&(tLogBuff->buffMutex));
free(tLogBuff->buffer);
t
aosTF
ree(tLogBuff);
t
f
ree(tLogBuff);
}
#endif
...
...
src/util/src/tmempool.c
浏览文件 @
9e663ecd
...
...
@@ -52,9 +52,9 @@ mpool_h taosMemPoolInit(int numOfBlock, int blockSize) {
if
(
pool_p
->
pool
==
NULL
||
pool_p
->
freeList
==
NULL
)
{
uError
(
"failed to allocate memory
\n
"
);
t
aosTF
ree
(
pool_p
->
freeList
);
t
aosTF
ree
(
pool_p
->
pool
);
t
aosTF
ree
(
pool_p
);
t
f
ree
(
pool_p
->
freeList
);
t
f
ree
(
pool_p
->
pool
);
t
f
ree
(
pool_p
);
return
NULL
;
}
...
...
src/util/src/tref.c
浏览文件 @
9e663ecd
...
...
@@ -484,8 +484,8 @@ static void taosDecRsetCount(SRefSet *pSet) {
pSet
->
max
=
0
;
pSet
->
fp
=
NULL
;
t
aosTF
ree
(
pSet
->
nodeList
);
t
aosTF
ree
(
pSet
->
lockedBy
);
t
f
ree
(
pSet
->
nodeList
);
t
f
ree
(
pSet
->
lockedBy
);
tsRefSetNum
--
;
uTrace
(
"rsetId:%d is cleaned, refSetNum:%d count:%d"
,
pSet
->
rsetId
,
tsRefSetNum
,
pSet
->
count
);
...
...
src/util/src/tskiplist.c
浏览文件 @
9e663ecd
...
...
@@ -27,7 +27,7 @@ static SSkipListIterator *doCreateSkipListIterator(SSkipList *pSkipList, int32_t
static
void
tSkipListDoInsert
(
SSkipList
*
pSkipList
,
SSkipListNode
**
forward
,
SSkipListNode
*
pNode
);
static
bool
tSkipListGetPosToPut
(
SSkipList
*
pSkipList
,
SSkipListNode
**
forward
,
void
*
pData
);
static
SSkipListNode
*
tSkipListNewNode
(
uint8_t
level
);
#define tSkipListFreeNode(n) t
aosTF
ree((n))
#define tSkipListFreeNode(n) t
f
ree((n))
static
FORCE_INLINE
int
tSkipListWLock
(
SSkipList
*
pSkipList
);
static
FORCE_INLINE
int
tSkipListRLock
(
SSkipList
*
pSkipList
);
...
...
@@ -97,12 +97,12 @@ void tSkipListDestroy(SSkipList *pSkipList) {
tSkipListUnlock
(
pSkipList
);
if
(
pSkipList
->
lock
!=
NULL
)
{
pthread_rwlock_destroy
(
pSkipList
->
lock
);
t
aosTF
ree
(
pSkipList
->
lock
);
t
f
ree
(
pSkipList
->
lock
);
}
tSkipListFreeNode
(
pSkipList
->
pHead
);
tSkipListFreeNode
(
pSkipList
->
pTail
);
t
aosTF
ree
(
pSkipList
);
t
f
ree
(
pSkipList
);
}
SSkipListNode
*
tSkipListPut
(
SSkipList
*
pSkipList
,
void
*
pData
)
{
...
...
@@ -265,7 +265,7 @@ void *tSkipListDestroyIter(SSkipListIterator *iter) {
return
NULL
;
}
t
aosTF
ree
(
iter
);
t
f
ree
(
iter
);
return
NULL
;
}
...
...
src/util/tests/skiplistTest.cpp
浏览文件 @
9e663ecd
...
...
@@ -59,7 +59,7 @@ void doubleSkipListTest() {
}
if (size > 0) {
t
aosTF
ree(pNodes);
t
f
ree(pNodes);
}
}
...
...
@@ -196,7 +196,7 @@ void stringKeySkiplistTest() {
tSkipListRemoveNode(pSkipList, pres[0]);
if (num > 0) {
t
aosTF
ree(pres);
t
f
ree(pres);
}
}
...
...
@@ -276,7 +276,7 @@ void skiplistPerformanceTest() {
assert
(
SL_GET_SIZE
(
pSkipList
)
==
size
);
tSkipListDestroy
(
pSkipList
);
t
aosTF
ree
(
total
);
t
f
ree
(
total
);
}
// todo not support duplicated key yet
...
...
@@ -357,7 +357,7 @@ TEST(testCase, skiplist_test) {
printf("-----%lf\n", pNodes[i]->key.dKey);
}
printf("the range query result size is: %d\n", size);
t
aosTF
ree(pNodes);
t
f
ree(pNodes);
SSkipListKey *pKeys = malloc(sizeof(SSkipListKey) * 20);
for (int32_t i = 0; i < 8; i += 2) {
...
...
@@ -371,7 +371,7 @@ TEST(testCase, skiplist_test) {
for (int32_t i = 0; i < r; ++i) {
// printf("%lf ", pNodes[i]->key.dKey);
}
t
aosTF
ree(pNodes);
t
f
ree(pNodes);
free(pKeys);*/
}
src/vnode/src/vnodeMain.c
浏览文件 @
9e663ecd
...
...
@@ -416,7 +416,7 @@ void vnodeRelease(void *pVnodeRaw) {
pVnode
->
rqueue
=
NULL
;
}
t
aosTF
ree
(
pVnode
->
rootDir
);
t
f
ree
(
pVnode
->
rootDir
);
if
(
pVnode
->
dropped
)
{
char
rootDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
...
...
src/wal/src/walMgmt.c
浏览文件 @
9e663ecd
...
...
@@ -28,14 +28,13 @@ typedef struct {
pthread_mutex_t
mutex
;
}
SWalMgmt
;
static
SWalMgmt
tsWal
;
static
SWalMgmt
tsWal
=
{
0
}
;
static
int32_t
walCreateThread
();
static
void
walStopThread
();
static
int32_t
walInitObj
(
SWal
*
pWal
);
static
void
walFreeObj
(
void
*
pWal
);
int32_t
walInit
()
{
tmemzero
(
&
tsWal
,
sizeof
(
SWalMgmt
));
tsWal
.
refId
=
taosOpenRef
(
TSDB_MIN_VNODES
,
walFreeObj
);
int32_t
code
=
walCreateThread
();
...
...
tests/tsim/src/simSystem.c
浏览文件 @
9e663ecd
...
...
@@ -103,9 +103,9 @@ void simFreeScript(SScript *script) {
simDebug
(
"script:%s, is freed"
,
script
->
fileName
);
taos_close
(
script
->
taos
);
t
aosTF
ree
(
script
->
lines
);
t
aosTF
ree
(
script
->
optionBuffer
);
t
aosTF
ree
(
script
);
t
f
ree
(
script
->
lines
);
t
f
ree
(
script
->
optionBuffer
);
t
f
ree
(
script
);
}
SScript
*
simProcessCallOver
(
SScript
*
script
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录