fix(query): fix syntax errors on centos.

This commit is contained in:
Haojun Liao 2023-02-24 11:38:54 +08:00
parent 97024f1468
commit 22aa03307c
69 changed files with 153 additions and 152 deletions

View File

@ -29,6 +29,7 @@ extern "C" {
#define calloc CALLOC_FUNC_TAOS_FORBID
#define realloc REALLOC_FUNC_TAOS_FORBID
#define free FREE_FUNC_TAOS_FORBID
#define strdup STRDUP_FUNC_TAOS_FORBID
#endif // ifndef ALLOW_FORBID_FUNC
#endif // if !defined(WINDOWS)
@ -38,7 +39,7 @@ int32_t taosMemoryDbgInitRestore();
void *taosMemoryMalloc(int64_t size);
void *taosMemoryCalloc(int64_t num, int64_t size);
void *taosMemoryRealloc(void *ptr, int64_t size);
void *taosMemoryStrDup(const char *ptr);
void *taosStrdup(const char *ptr);
void taosMemoryFree(void *ptr);
int64_t taosMemorySize(void *ptr);
void taosPrintBackTrace();

View File

@ -758,7 +758,7 @@ static void *hbThreadFunc(void *param) {
pInfo->msgInfo.pData = buf;
pInfo->msgInfo.len = tlen;
pInfo->msgType = TDMT_MND_HEARTBEAT;
pInfo->param = strdup(pAppHbMgr->key);
pInfo->param = taosStrdup(pAppHbMgr->key);
pInfo->paramFreeFp = taosMemoryFree;
pInfo->requestId = generateRequestId();
pInfo->requestObjRefId = 0;
@ -826,7 +826,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
pAppHbMgr->connKeyCnt = 0;
pAppHbMgr->reportCnt = 0;
pAppHbMgr->reportBytes = 0;
pAppHbMgr->key = strdup(key);
pAppHbMgr->key = taosStrdup(key);
// init app info
pAppHbMgr->pAppInstInfo = pAppInstInfo;

View File

@ -52,7 +52,7 @@ static bool validateDbName(const char* db) { return stringLengthCheck(db, TSDB_D
static char* getClusterKey(const char* user, const char* auth, const char* ip, int32_t port) {
char key[512] = {0};
snprintf(key, sizeof(key), "%s:%s:%s:%d", user, auth, ip, port);
return strdup(key);
return taosStrdup(key);
}
bool chkRequestKilled(void* param) {

View File

@ -330,15 +330,15 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
}
if (strcmp(key, "td.connect.ip") == 0) {
conf->ip = strdup(value);
conf->ip = taosStrdup(value);
return TMQ_CONF_OK;
}
if (strcmp(key, "td.connect.user") == 0) {
conf->user = strdup(value);
conf->user = taosStrdup(value);
return TMQ_CONF_OK;
}
if (strcmp(key, "td.connect.pass") == 0) {
conf->pass = strdup(value);
conf->pass = taosStrdup(value);
return TMQ_CONF_OK;
}
if (strcmp(key, "td.connect.port") == 0) {
@ -346,7 +346,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
return TMQ_CONF_OK;
}
if (strcmp(key, "td.connect.db") == 0) {
/*conf->db = strdup(value);*/
/*conf->db = taosStrdup(value);*/
return TMQ_CONF_OK;
}
@ -361,7 +361,7 @@ tmq_list_t* tmq_list_new() {
int32_t tmq_list_append(tmq_list_t* list, const char* src) {
SArray* container = &list->container;
if (src == NULL || src[0] == 0) return -1;
char* topic = strdup(src);
char* topic = taosStrdup(src);
if (topic[0] != '`') {
strtolower(topic, src);
}

View File

@ -185,7 +185,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
pDst->arr = taosArrayInit(num, sizeof(char *));
for (size_t i = 0; i < num; i++) {
char *p = (char *)taosArrayGetP(pSrc->arr, i);
char *n = strdup(p);
char *n = taosStrdup(p);
taosArrayPush(pDst->arr, &n);
}
} else if (pSrc->nType == TSDB_DATA_TYPE_VALUE_ARRAY) {

View File

@ -53,7 +53,7 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
pVnode->vgVersion = pCfg->vgVersion;
pVnode->refCount = 0;
pVnode->dropped = 0;
pVnode->path = tstrdup(pCfg->path);
pVnode->path = taosStrdup(pCfg->path);
pVnode->pImpl = pImpl;
if (pVnode->path == NULL) {

View File

@ -124,7 +124,7 @@ int32_t dmInitDnode(SDnode *pDnode) {
taosThreadRwlockInit(&pWrapper->lock, NULL);
snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name);
pWrapper->path = strdup(path);
pWrapper->path = taosStrdup(path);
if (pWrapper->path == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto _OVER;

View File

@ -577,7 +577,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
subscribe.topicNames = NULL;
for (int32_t i = 0; i < newTopicNum; i++) {
char *newTopicCopy = strdup(taosArrayGetP(newSub, i));
char *newTopicCopy = taosStrdup(taosArrayGetP(newSub, i));
taosArrayPush(pConsumerNew->assignedTopics, &newTopicCopy);
}
@ -605,7 +605,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
pConsumerNew->updateType = CONSUMER_UPDATE__MODIFY;
for (int32_t i = 0; i < newTopicNum; i++) {
char *newTopicCopy = strdup(taosArrayGetP(newSub, i));
char *newTopicCopy = taosStrdup(taosArrayGetP(newSub, i));
taosArrayPush(pConsumerNew->assignedTopics, &newTopicCopy);
}
@ -617,12 +617,12 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
int32_t i = 0, j = 0;
while (i < oldTopicNum || j < newTopicNum) {
if (i >= oldTopicNum) {
char *newTopicCopy = strdup(taosArrayGetP(newSub, j));
char *newTopicCopy = taosStrdup(taosArrayGetP(newSub, j));
taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy);
j++;
continue;
} else if (j >= newTopicNum) {
char *oldTopicCopy = strdup(taosArrayGetP(pConsumerOld->currentTopics, i));
char *oldTopicCopy = taosStrdup(taosArrayGetP(pConsumerOld->currentTopics, i));
taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy);
i++;
continue;
@ -635,12 +635,12 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
j++;
continue;
} else if (comp < 0) {
char *oldTopicCopy = strdup(oldTopic);
char *oldTopicCopy = taosStrdup(oldTopic);
taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy);
i++;
continue;
} else {
char *newTopicCopy = strdup(newTopic);
char *newTopicCopy = taosStrdup(newTopic);
taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy);
j++;
continue;
@ -808,7 +808,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
int32_t sz = taosArrayGetSize(pOldConsumer->currentTopics);
/*pOldConsumer->rebRemovedTopics = taosArrayInit(sz, sizeof(void *));*/
for (int32_t i = 0; i < sz; i++) {
char *topic = strdup(taosArrayGetP(pOldConsumer->currentTopics, i));
char *topic = taosStrdup(taosArrayGetP(pOldConsumer->currentTopics, i));
taosArrayPush(pOldConsumer->rebRemovedTopics, &topic);
}
@ -821,7 +821,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
int32_t sz = taosArrayGetSize(pOldConsumer->assignedTopics);
for (int32_t i = 0; i < sz; i++) {
char *topic = strdup(taosArrayGetP(pOldConsumer->assignedTopics, i));
char *topic = taosStrdup(taosArrayGetP(pOldConsumer->assignedTopics, i));
taosArrayPush(pOldConsumer->rebNewTopics, &topic);
}
@ -837,7 +837,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
/*A(taosArrayGetSize(pNewConsumer->rebNewTopics) == 1);*/
/*A(taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0);*/
char *addedTopic = strdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0));
char *addedTopic = taosStrdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0));
// not exist in current topic
bool existing = false;

View File

@ -181,7 +181,7 @@ SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
SMqVgEp *pVgEpNew = taosMemoryMalloc(sizeof(SMqVgEp));
if (pVgEpNew == NULL) return NULL;
pVgEpNew->vgId = pVgEp->vgId;
pVgEpNew->qmsg = strdup(pVgEp->qmsg);
pVgEpNew->qmsg = taosStrdup(pVgEp->qmsg);
pVgEpNew->epSet = pVgEp->epSet;
return pVgEpNew;
}

View File

@ -322,7 +322,7 @@ static void mndCleanupTimer(SMnode *pMnode) {
}
static int32_t mndCreateDir(SMnode *pMnode, const char *path) {
pMnode->path = strdup(path);
pMnode->path = taosStrdup(path);
if (pMnode->path == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;

View File

@ -587,7 +587,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
return -1;
}
} else {
pVgEp->qmsg = strdup("");
pVgEp->qmsg = taosStrdup("");
}
sdbRelease(pSdb, pVgroup);

View File

@ -552,14 +552,14 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
streamObj.sourceDbUid = pDb->uid;
streamObj.targetDbUid = pDb->uid;
streamObj.version = 1;
streamObj.sql = strdup(pCreate->sql);
streamObj.sql = taosStrdup(pCreate->sql);
streamObj.smaId = smaObj.uid;
streamObj.watermark = pCreate->watermark;
streamObj.deleteMark = pCreate->deleteMark;
streamObj.fillHistory = STREAM_FILL_HISTORY_ON;
streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE;
streamObj.triggerParam = pCreate->maxDelay;
streamObj.ast = strdup(smaObj.ast);
streamObj.ast = taosStrdup(smaObj.ast);
// check the maxDelay
if (streamObj.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) {

View File

@ -1734,7 +1734,7 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName,
pRsp->ttl = pStb->ttl;
pRsp->commentLen = pStb->commentLen;
if (pStb->commentLen > 0) {
pRsp->pComment = strdup(pStb->comment);
pRsp->pComment = taosStrdup(pStb->comment);
}
for (int32_t i = 0; i < pStb->numOfColumns; ++i) {

View File

@ -379,7 +379,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
topicObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
topicObj.dbUid = pDb->uid;
topicObj.version = 1;
topicObj.sql = strdup(pCreate->sql);
topicObj.sql = taosStrdup(pCreate->sql);
topicObj.sqlLen = strlen(pCreate->sql) + 1;
topicObj.subType = pCreate->subType;
topicObj.withMeta = pCreate->withMeta;
@ -392,7 +392,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
}
if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) {
topicObj.ast = strdup(pCreate->ast);
topicObj.ast = taosStrdup(pCreate->ast);
topicObj.astLen = strlen(pCreate->ast) + 1;
qDebugL("ast %s", topicObj.ast);

View File

@ -124,7 +124,7 @@ class MndTestTrans2 : public ::testing::Test {
mndTransAppendUndolog(pTrans, pUndoRaw);
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED);
char *param = strdup("====> test log <=====");
char *param = taosStrdup("====> test log <=====");
mndTransSetCb(pTrans, TRANS_START_FUNC_TEST, TRANS_STOP_FUNC_TEST, param, strlen(param) + 1);
if (pDb != NULL) {
@ -157,7 +157,7 @@ class MndTestTrans2 : public ::testing::Test {
mndTransAppendUndolog(pTrans, pUndoRaw);
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED);
char *param = strdup("====> test action <=====");
char *param = taosStrdup("====> test action <=====");
mndTransSetCb(pTrans, TRANS_START_FUNC_TEST, TRANS_STOP_FUNC_TEST, param, strlen(param) + 1);
{
@ -229,7 +229,7 @@ class MndTestTrans2 : public ::testing::Test {
mndTransAppendUndolog(pTrans, pUndoRaw);
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED);
char *param = strdup("====> test log <=====");
char *param = taosStrdup("====> test log <=====");
mndTransSetCb(pTrans, TRANS_START_FUNC_TEST, TRANS_STOP_FUNC_TEST, param, strlen(param) + 1);
int32_t code = mndTransPrepare(pMnode, pTrans);

View File

@ -30,9 +30,9 @@ SSdb *sdbInit(SSdbOpt *pOption) {
char path[PATH_MAX + 100] = {0};
snprintf(path, sizeof(path), "%s%sdata", pOption->path, TD_DIRSEP);
pSdb->currDir = strdup(path);
pSdb->currDir = taosStrdup(path);
snprintf(path, sizeof(path), "%s%stmp", pOption->path, TD_DIRSEP);
pSdb->tmpDir = strdup(path);
pSdb->tmpDir = taosStrdup(path);
if (pSdb->currDir == NULL || pSdb->tmpDir == NULL) {
sdbCleanup(pSdb);
terrno = TSDB_CODE_OUT_OF_MEMORY;

View File

@ -521,7 +521,7 @@ static SSdbIter *sdbCreateIter(SSdb *pSdb) {
char name[PATH_MAX + 100] = {0};
snprintf(name, sizeof(name), "%s%ssdb.data.%" PRIu64, pSdb->tmpDir, TD_DIRSEP, (uint64_t)pIter);
pIter->name = strdup(name);
pIter->name = taosStrdup(name);
if (pIter->name == NULL) {
taosMemoryFree(pIter);
terrno = TSDB_CODE_OUT_OF_MEMORY;

View File

@ -104,7 +104,7 @@ SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
pSnode->path = strdup(path);
pSnode->path = taosStrdup(path);
if (pSnode->path == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto FAIL;

View File

@ -252,7 +252,7 @@ static void saveSuperTableInfoForChildTable(SMetaEntry* me, SHashObj* suidInfo)
return;
}
STableInfoForChildTable dataTmp = {0};
dataTmp.tableName = strdup(me->name);
dataTmp.tableName = taosStrdup(me->name);
dataTmp.schemaRow = tCloneSSchemaWrapper(&me->stbEntry.schemaRow);
dataTmp.tagRow = tCloneSSchemaWrapper(&me->stbEntry.schemaTag);

View File

@ -262,7 +262,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
// set the backend of stream state
tdRSmaQTaskInfoGetFullPathEx(TD_VID(pVnode), pRSmaInfo->suid, idx + 1, tfsGetPrimaryPath(pVnode->pTfs), taskInfDir);
if (!taosCheckExistFile(taskInfDir)) {
char *s = strdup(taskInfDir);
char *s = taosStrdup(taskInfDir);
if (taosMulMkDir(taosDirName(s)) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
taosMemoryFree(s);

View File

@ -208,7 +208,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
// set super table name
SName name = {0};
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
pCreateTbReq->ctb.stbName = strdup((char *)tNameGetTableName(&name)); // strdup(stbFullName);
pCreateTbReq->ctb.stbName = taosStrdup((char *)tNameGetTableName(&name)); // taosStrdup(stbFullName);
// set tag content
taosArrayClear(tagArray);
@ -237,7 +237,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
// set table name
if (pDataBlock->info.parTbName[0]) {
pCreateTbReq->name = strdup(pDataBlock->info.parTbName);
pCreateTbReq->name = taosStrdup(pDataBlock->info.parTbName);
} else {
pCreateTbReq->name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId);
}

View File

@ -78,7 +78,7 @@ STQ* tqOpen(const char* path, SVnode* pVnode) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
pTq->path = strdup(path);
pTq->path = taosStrdup(path);
pTq->pVnode = pVnode;
pTq->walLogLastVer = pVnode->pWal->vers.lastVer;

View File

@ -52,7 +52,7 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, in
return -1;
}
for (int32_t i = 0; i < n; i++) {
char* tbName = strdup(mr.me.name);
char* tbName = taosStrdup(mr.me.name);
taosArrayPush(pRsp->blockTbName, &tbName);
}
metaReaderClear(&mr);
@ -157,7 +157,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
continue;
}
} else {
char* tbName = strdup(qExtractTbnameFromTask(task));
char* tbName = taosStrdup(qExtractTbnameFromTask(task));
taosArrayPush(pRsp->blockTbName, &tbName);
}
}

View File

@ -130,7 +130,7 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
char* ctbName = NULL;
// set child table name
if (pDataBlock->info.parTbName[0]) {
ctbName = strdup(pDataBlock->info.parTbName);
ctbName = taosStrdup(pDataBlock->info.parTbName);
} else {
ctbName = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId);
}
@ -155,7 +155,7 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
// set super table name
SName name = {0};
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
createTbReq.ctb.stbName = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName);
createTbReq.ctb.stbName = taosStrdup((char*)tNameGetTableName(&name)); // taosStrdup(stbFullName);
createTbReq.name = ctbName;
ctbName = NULL;
@ -453,7 +453,7 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
// set super table name
SName name = {0};
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
pCreateTbReq->ctb.stbName = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName);
pCreateTbReq->ctb.stbName = taosStrdup((char*)tNameGetTableName(&name)); // taosStrdup(stbFullName);
// set tag content
int32_t size = taosArrayGetSize(pDataBlock->pDataBlock);
@ -544,7 +544,7 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
char* ctbName = NULL;
tqDebug("vgId:%d, stream write into %s, table auto created", TD_VID(pVnode), pDataBlock->info.parTbName);
if (pDataBlock->info.parTbName[0]) {
ctbName = strdup(pDataBlock->info.parTbName);
ctbName = taosStrdup(pDataBlock->info.parTbName);
} else {
ctbName = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId);
}
@ -569,7 +569,7 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
// set super table name
SName name = {0};
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
pCreateTbReq->ctb.stbName = strdup((char*)tNameGetTableName(&name)); // strdup(stbFullName);
pCreateTbReq->ctb.stbName = taosStrdup((char*)tNameGetTableName(&name)); // taosStrdup(stbFullName);
// set tag content
tagArray = taosArrayInit(1, sizeof(STagVal));

View File

@ -190,7 +190,7 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
return TSDB_CODE_OUT_OF_MEMORY;
}
p->idstr = taosMemoryStrDup(idstr);
p->idstr = taosStrdup(idstr);
taosThreadMutexInit(&p->readerMutex, NULL);
*pReader = p;

View File

@ -677,7 +677,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
pReader->order = pCond->order;
pReader->capacity = capacity;
pReader->pResBlock = pResBlock;
pReader->idStr = (idstr != NULL) ? strdup(idstr) : NULL;
pReader->idStr = (idstr != NULL) ? taosStrdup(idstr) : NULL;
pReader->verRange = getQueryVerRange(pVnode, pCond, level);
pReader->type = pCond->type;
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows);

View File

@ -197,7 +197,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
cfgRsp.ttl = mer1.me.ctbEntry.ttlDays;
cfgRsp.commentLen = mer1.me.ctbEntry.commentLen;
if (mer1.me.ctbEntry.commentLen > 0) {
cfgRsp.pComment = strdup(mer1.me.ctbEntry.comment);
cfgRsp.pComment = taosStrdup(mer1.me.ctbEntry.comment);
}
STag *pTag = (STag *)mer1.me.ctbEntry.pTags;
cfgRsp.tagsLen = pTag->len;
@ -208,7 +208,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
cfgRsp.ttl = mer1.me.ntbEntry.ttlDays;
cfgRsp.commentLen = mer1.me.ntbEntry.commentLen;
if (mer1.me.ntbEntry.commentLen > 0) {
cfgRsp.pComment = strdup(mer1.me.ntbEntry.comment);
cfgRsp.pComment = taosStrdup(mer1.me.ntbEntry.comment);
}
} else {
ASSERT(0);

View File

@ -281,7 +281,7 @@ int32_t ctgdHandleDbgCommand(char *command) {
CTG_RET(TSDB_CODE_INVALID_PARA);
}
char *dup = strdup(command);
char *dup = taosStrdup(command);
char *option = NULL;
char *param = NULL;

View File

@ -742,7 +742,7 @@ int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* targ
pCtx->reqType = reqType;
pCtx->out = out;
if (target) {
pCtx->target = strdup(target);
pCtx->target = taosStrdup(target);
if (NULL == pCtx->target) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
@ -759,7 +759,7 @@ int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target) {
ctx.reqType = reqType;
ctx.out = out;
if (target) {
ctx.target = strdup(target);
ctx.target = taosStrdup(target);
if (NULL == ctx.target) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
@ -1169,7 +1169,7 @@ int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes) {
for (int32_t i = 0; i < num; ++i) {
STableIndexInfo* pInfo = taosArrayGet(pIndex, i);
pInfo = taosArrayPush(*pRes, pInfo);
pInfo->expr = strdup(pInfo->expr);
pInfo->expr = taosStrdup(pInfo->expr);
}
return TSDB_CODE_SUCCESS;
@ -1179,7 +1179,7 @@ int32_t ctgUpdateSendTargetInfo(SMsgSendInfo* pMsgSendInfo, int32_t msgType, cha
if (msgType == TDMT_VND_TABLE_META || msgType == TDMT_VND_TABLE_CFG || msgType == TDMT_VND_BATCH_META) {
pMsgSendInfo->target.type = TARGET_TYPE_VNODE;
pMsgSendInfo->target.vgId = vgId;
pMsgSendInfo->target.dbFName = strdup(dbFName);
pMsgSendInfo->target.dbFName = taosStrdup(dbFName);
} else {
pMsgSendInfo->target.type = TARGET_TYPE_MNODE;
}

View File

@ -1529,7 +1529,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet);
} else {
char* udfName = pExpr->pExpr->_function.pFunctNode->functionName;
pCtx->udfName = strdup(udfName);
pCtx->udfName = taosStrdup(udfName);
fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet);
}
pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env);

View File

@ -2000,7 +2000,7 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
pTaskInfo->schemaInfo.dbname = strdup(dbFName);
pTaskInfo->schemaInfo.dbname = taosStrdup(dbFName);
pTaskInfo->execModel = model;
pTaskInfo->pTableInfoList = tableListCreate();
pTaskInfo->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo));
@ -2026,7 +2026,7 @@ int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode,
}
SSchemaInfo* pSchemaInfo = &pTaskInfo->schemaInfo;
pSchemaInfo->tablename = strdup(mr.me.name);
pSchemaInfo->tablename = taosStrdup(mr.me.name);
if (mr.me.type == TSDB_SUPER_TABLE) {
pSchemaInfo->sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);

View File

@ -434,7 +434,7 @@ static void freeTableCachedVal(void* param) {
static STableCachedVal* createTableCacheVal(const SMetaReader* pMetaReader) {
STableCachedVal* pVal = taosMemoryMalloc(sizeof(STableCachedVal));
pVal->pName = strdup(pMetaReader->me.name);
pVal->pName = taosStrdup(pMetaReader->me.name);
pVal->pTags = NULL;
// only child table has tag value

View File

@ -1709,7 +1709,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
extractTbnameSlotId(pInfo, pScanNode);
pInfo->accountId = pScanPhyNode->accountId;
pInfo->pUser = taosMemoryStrDup((void*)pUser);
pInfo->pUser = taosStrdup((void*)pUser);
pInfo->sysInfo = pScanPhyNode->sysInfo;
pInfo->showRewrite = pScanPhyNode->showRewrite;
pInfo->pRes = createDataBlockFromDescNode(pDescNode);

View File

@ -90,7 +90,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
tsortSetComparFp(pSortHandle, msortComparFn);
if (idstr != NULL) {
pSortHandle->idStr = strdup(idstr);
pSortHandle->idStr = taosStrdup(idstr);
}
return pSortHandle;

View File

@ -126,7 +126,7 @@ int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
idx->colObj = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
idx->version = 1;
idx->path = tstrdup(path);
idx->path = taosStrdup(path);
taosThreadMutexInit(&idx->mtx, NULL);
tsem_init(&idx->sem, 0, 0);

View File

@ -340,7 +340,7 @@ IndexCache* idxCacheCreate(SIndex* idx, uint64_t suid, const char* colName, int8
cache->mem = idxInternalCacheCreate(type);
cache->mem->pCache = cache;
cache->colName = IDX_TYPE_CONTAIN_EXTERN_TYPE(type, TSDB_DATA_TYPE_JSON) ? tstrdup(JSON_COLUMN) : tstrdup(colName);
cache->colName = IDX_TYPE_CONTAIN_EXTERN_TYPE(type, TSDB_DATA_TYPE_JSON) ? taosStrdup(JSON_COLUMN) : taosStrdup(colName);
cache->type = type;
cache->index = idx;
cache->version = 0;
@ -767,7 +767,7 @@ static bool idxCacheIteratorNext(Iterate* itera) {
iv->type = ct->operaType;
iv->ver = ct->version;
iv->colVal = tstrdup(ct->colVal);
iv->colVal = taosStrdup(ct->colVal);
taosArrayPush(iv->val, &ct->uid);
}
return next;

View File

@ -164,7 +164,7 @@ FAutoCtx* automCtxCreate(void* data, AutomationType atype) {
// add more search type
}
ctx->data = (data != NULL ? strdup((char*)data) : NULL);
ctx->data = (data != NULL ? taosStrdup((char*)data) : NULL);
ctx->type = atype;
ctx->stdata = (void*)sv;
return ctx;

View File

@ -23,7 +23,7 @@ FstRegex *regexCreate(const char *str) {
return NULL;
}
regex->orig = tstrdup(str);
regex->orig = taosStrdup(str);
// construct insts based on str
SArray *insts = taosArrayInit(256, sizeof(uint8_t));

View File

@ -804,7 +804,7 @@ TFileValue* tfileValueCreate(char* val) {
if (tf == NULL) {
return NULL;
}
tf->colVal = tstrdup(val);
tf->colVal = taosStrdup(val);
tf->tableId = taosArrayInit(32, sizeof(uint64_t));
return tf;
}

View File

@ -599,7 +599,7 @@ void validateTFile(char* arg) {
std::thread threads[NUM_OF_THREAD];
// std::vector<std::thread> threads;
SIndex* index = (SIndex*)taosMemoryCalloc(1, sizeof(SIndex));
index->path = strdup(arg);
index->path = taosStrdup(arg);
TFileReader* reader = tfileReaderOpen(index, 0, 20000000, "tag1");
for (int i = 0; i < NUM_OF_THREAD; i++) {

View File

@ -40,7 +40,7 @@
if (NULL == (pSrc)->fldname) { \
break; \
} \
(pDst)->fldname = strdup((pSrc)->fldname); \
(pDst)->fldname = taosStrdup((pSrc)->fldname); \
if (NULL == (pDst)->fldname) { \
return TSDB_CODE_OUT_OF_MEMORY; \
} \

View File

@ -28,7 +28,7 @@ static EDealRes rewriterTest(SNode** pNode, void* pContext) {
}
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
string tmp = to_string(stoi(((SValueNode*)(pOp->pLeft))->literal) + stoi(((SValueNode*)(pOp->pRight))->literal));
pVal->literal = strdup(tmp.c_str());
pVal->literal = taosStrdup(tmp.c_str());
nodesDestroyNode(*pNode);
*pNode = (SNode*)pVal;
}
@ -40,12 +40,12 @@ TEST(NodesTest, traverseTest) {
SOperatorNode* pOp = (SOperatorNode*)pRoot;
SOperatorNode* pLeft = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
pLeft->pLeft = (SNode*)nodesMakeNode(QUERY_NODE_VALUE);
((SValueNode*)(pLeft->pLeft))->literal = strdup("10");
((SValueNode*)(pLeft->pLeft))->literal = taosStrdup("10");
pLeft->pRight = (SNode*)nodesMakeNode(QUERY_NODE_VALUE);
((SValueNode*)(pLeft->pRight))->literal = strdup("5");
((SValueNode*)(pLeft->pRight))->literal = taosStrdup("5");
pOp->pLeft = (SNode*)pLeft;
pOp->pRight = (SNode*)nodesMakeNode(QUERY_NODE_VALUE);
((SValueNode*)(pOp->pRight))->literal = strdup("3");
((SValueNode*)(pOp->pRight))->literal = taosStrdup("3");
EXPECT_EQ(nodeType(pRoot), QUERY_NODE_OPERATOR);
EDealRes res = DEAL_RES_CONTINUE;

View File

@ -355,7 +355,7 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
CHECK_OUT_OF_MEM(val);
val->literal = strdup(pCxt->pQueryCxt->db);
val->literal = taosStrdup(pCxt->pQueryCxt->db);
CHECK_OUT_OF_MEM(val->literal);
val->isDuration = false;
val->translate = false;

View File

@ -449,7 +449,7 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema,
if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) {
return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
}
val->pData = strdup(pToken->z);
val->pData = taosStrdup(pToken->z);
val->nData = pToken->n;
break;
}

View File

@ -144,10 +144,10 @@ int16_t insFindCol(SToken* pColname, int16_t start, int16_t end, SSchema* pSchem
void insBuildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname,
SArray* tagName, uint8_t tagNum, int32_t ttl) {
pTbReq->type = TD_CHILD_TABLE;
pTbReq->name = strdup(tname);
pTbReq->name = taosStrdup(tname);
pTbReq->ctb.suid = suid;
pTbReq->ctb.tagNum = tagNum;
if (sname) pTbReq->ctb.stbName = strdup(sname);
if (sname) pTbReq->ctb.stbName = taosStrdup(sname);
pTbReq->ctb.pTag = (uint8_t*)pTag;
pTbReq->ctb.tagName = taosArrayDup(tagName, NULL);
pTbReq->ttl = ttl;

View File

@ -1692,7 +1692,7 @@ static int32_t rewriteFuncToValue(STranslateContext* pCxt, char* pLiteral, SNode
static int32_t rewriteDatabaseFunc(STranslateContext* pCxt, SNode** pNode) {
char* pCurrDb = NULL;
if (NULL != pCxt->pParseCxt->db) {
pCurrDb = taosMemoryStrDup((void*)pCxt->pParseCxt->db);
pCurrDb = taosStrdup((void*)pCxt->pParseCxt->db);
if (NULL == pCurrDb) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -1701,7 +1701,7 @@ static int32_t rewriteDatabaseFunc(STranslateContext* pCxt, SNode** pNode) {
}
static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
char* pVer = taosMemoryStrDup((void*)version);
char* pVer = taosStrdup((void*)version);
if (NULL == pVer) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -1709,7 +1709,7 @@ static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
}
static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode) {
char* pVer = taosMemoryStrDup((void*)pCxt->pParseCxt->svrVer);
char* pVer = taosStrdup((void*)pCxt->pParseCxt->svrVer);
if (NULL == pVer) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -1720,7 +1720,7 @@ static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
if (pCxt->pParseCxt->nodeOffline) {
return TSDB_CODE_RPC_NETWORK_UNAVAIL;
}
char* pStatus = taosMemoryStrDup((void*)"1");
char* pStatus = taosStrdup((void*)"1");
return rewriteFuncToValue(pCxt, pStatus, pNode);
}
@ -1728,7 +1728,7 @@ static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
char userConn[TSDB_USER_LEN + 1 + TSDB_FQDN_LEN] = {0}; // format 'user@host'
int32_t len = snprintf(userConn, sizeof(userConn), "%s@", pCxt->pParseCxt->pUser);
taosGetFqdn(userConn + len);
char* pUserConn = taosMemoryStrDup((void*)userConn);
char* pUserConn = taosStrdup((void*)userConn);
if (NULL == pUserConn) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -4910,7 +4910,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
if (pStmt->pOptions->commentNull == false) {
pReq->pComment = strdup(pStmt->pOptions->comment);
pReq->pComment = taosStrdup(pStmt->pOptions->comment);
if (NULL == pReq->pComment) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -4978,7 +4978,7 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt*
if (TSDB_ALTER_TABLE_UPDATE_OPTIONS == pStmt->alterType) {
// pAlterReq->ttl = pStmt->pOptions->ttl;
if (pStmt->pOptions->commentNull == false) {
pAlterReq->comment = strdup(pStmt->pOptions->comment);
pAlterReq->comment = taosStrdup(pStmt->pOptions->comment);
if (NULL == pAlterReq->comment) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -5267,7 +5267,7 @@ static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, const char* pDbName,
}
static int32_t getSmaIndexSql(STranslateContext* pCxt, char** pSql, int32_t* pLen) {
*pSql = strdup(pCxt->pParseCxt->pSql);
*pSql = taosStrdup(pCxt->pParseCxt->pSql);
if (NULL == *pSql) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -5505,7 +5505,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
pReq->igExists = pStmt->ignoreExists;
pReq->withMeta = pStmt->withMeta;
pReq->sql = strdup(pCxt->pParseCxt->pSql);
pReq->sql = taosStrdup(pCxt->pParseCxt->pSql);
if (NULL == pReq->sql) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -6252,7 +6252,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
int32_t code = buildCreateStreamQuery(pCxt, pStmt, pReq);
if (TSDB_CODE_SUCCESS == code) {
pReq->sql = strdup(pCxt->pParseCxt->pSql);
pReq->sql = taosStrdup(pCxt->pParseCxt->pSql);
if (NULL == pReq->sql) {
code = TSDB_CODE_OUT_OF_MEMORY;
}
@ -7144,10 +7144,10 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
SVCreateTbReq req = {0};
req.type = TD_NORMAL_TABLE;
req.name = strdup(pStmt->tableName);
req.name = taosStrdup(pStmt->tableName);
req.ttl = pStmt->pOptions->ttl;
if (pStmt->pOptions->commentNull == false) {
req.comment = strdup(pStmt->pOptions->comment);
req.comment = taosStrdup(pStmt->pOptions->comment);
if (NULL == req.comment) {
tdDestroySVCreateTbReq(&req);
return TSDB_CODE_OUT_OF_MEMORY;
@ -7306,17 +7306,17 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
struct SVCreateTbReq req = {0};
req.type = TD_CHILD_TABLE;
req.name = strdup(pStmt->tableName);
req.name = taosStrdup(pStmt->tableName);
req.ttl = pStmt->pOptions->ttl;
if (pStmt->pOptions->commentNull == false) {
req.comment = strdup(pStmt->pOptions->comment);
req.comment = taosStrdup(pStmt->pOptions->comment);
req.commentLen = strlen(pStmt->pOptions->comment);
} else {
req.commentLen = -1;
}
req.ctb.suid = suid;
req.ctb.tagNum = tagNum;
req.ctb.stbName = strdup(sTableNmae);
req.ctb.stbName = taosStrdup(sTableNmae);
req.ctb.pTag = (uint8_t*)pTag;
req.ctb.tagName = taosArrayDup(tagName, NULL);
if (pStmt->ignoreExists) {
@ -7798,7 +7798,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
pStmt->colName);
}
pReq->tagName = strdup(pStmt->colName);
pReq->tagName = taosStrdup(pStmt->colName);
if (NULL == pReq->tagName) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -7871,7 +7871,7 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ROW_LENGTH, TSDB_MAX_BYTES_PER_ROW);
}
pReq->colName = strdup(pStmt->colName);
pReq->colName = taosStrdup(pStmt->colName);
if (NULL == pReq->colName) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -7894,7 +7894,7 @@ static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt,
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_CANNOT_DROP_PRIMARY_KEY);
}
pReq->colName = strdup(pStmt->colName);
pReq->colName = taosStrdup(pStmt->colName);
if (NULL == pReq->colName) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -7919,7 +7919,7 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ROW_LENGTH, TSDB_MAX_BYTES_PER_ROW);
}
pReq->colName = strdup(pStmt->colName);
pReq->colName = taosStrdup(pStmt->colName);
if (NULL == pReq->colName) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -7937,8 +7937,8 @@ static int32_t buildRenameColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DUPLICATED_COLUMN);
}
pReq->colName = strdup(pStmt->colName);
pReq->colNewName = strdup(pStmt->newColName);
pReq->colName = taosStrdup(pStmt->colName);
pReq->colNewName = taosStrdup(pStmt->newColName);
if (NULL == pReq->colName || NULL == pReq->colNewName) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -7955,7 +7955,7 @@ static int32_t buildUpdateOptionsReq(STranslateContext* pCxt, SAlterTableStmt* p
if (TSDB_CODE_SUCCESS == code) {
if (pStmt->pOptions->commentNull == false) {
pReq->newComment = strdup(pStmt->pOptions->comment);
pReq->newComment = taosStrdup(pStmt->pOptions->comment);
if (NULL == pReq->newComment) {
code = TSDB_CODE_OUT_OF_MEMORY;
} else {
@ -7971,7 +7971,7 @@ static int32_t buildUpdateOptionsReq(STranslateContext* pCxt, SAlterTableStmt* p
static int32_t buildAlterTbReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
SVAlterTbReq* pReq) {
pReq->tbName = strdup(pStmt->tableName);
pReq->tbName = taosStrdup(pStmt->tableName);
if (NULL == pReq->tbName) {
return TSDB_CODE_OUT_OF_MEMORY;
}

View File

@ -971,7 +971,7 @@ static SArray* smaIndexesDup(SArray* pSrc) {
}
for (int32_t i = 0; i < size; ++i) {
STableIndexInfo* pIndex = taosArrayGet(pDst, i);
pIndex->expr = taosMemoryStrDup(((STableIndexInfo*)taosArrayGet(pSrc, i))->expr);
pIndex->expr = taosStrdup(((STableIndexInfo*)taosArrayGet(pSrc, i))->expr);
if (NULL == pIndex->expr) {
taosArrayDestroyEx(pDst, destroySmaIndex);
return NULL;

View File

@ -331,7 +331,7 @@ class MockCatalogServiceImpl {
info.dstTbUid = getNextId();
info.dstVgId = pReq->dstVgId;
genEpSet(&info.epSet);
info.expr = strdup(pReq->expr);
info.expr = taosStrdup(pReq->expr);
auto it = index_.find(pReq->stb);
if (index_.end() == it) {
index_.insert(std::make_pair(string(pReq->stb), std::vector<STableIndexInfo>{info}));
@ -374,7 +374,7 @@ class MockCatalogServiceImpl {
STableIndexInfo* copyTableIndexInfo(STableIndexInfo* pDst, const STableIndexInfo* pSrc) const {
memcpy(pDst, pSrc, sizeof(STableIndexInfo));
pDst->expr = strdup(pSrc->expr);
pDst->expr = taosStrdup(pSrc->expr);
return pDst;
}

View File

@ -382,7 +382,7 @@ TEST_F(ParserInitialATest, alterSTable) {
expect.name[len] = '\0';
expect.alterType = alterType;
if (nullptr != pComment) {
expect.comment = strdup(pComment);
expect.comment = taosStrdup(pComment);
expect.commentLen = strlen(pComment);
}

View File

@ -603,7 +603,7 @@ TEST_F(ParserInitialCTest, createStable) {
expect.deleteMark2 = deleteMark2;
// expect.ttl = ttl;
if (nullptr != pComment) {
expect.pComment = strdup(pComment);
expect.pComment = taosStrdup(pComment);
expect.commentLen = strlen(pComment);
}
};
@ -780,7 +780,7 @@ TEST_F(ParserInitialCTest, createStream) {
snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb);
snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb);
expect.igExists = igExists;
expect.sql = strdup(pSql);
expect.sql = taosStrdup(pSql);
expect.createStb = STREAM_CREATE_STABLE_TRUE;
expect.triggerType = STREAM_TRIGGER_AT_ONCE;
expect.maxDelay = 0;
@ -934,13 +934,13 @@ TEST_F(ParserInitialCTest, createTable) {
auto addCreateTbReq = [&](const char* pName, bool ignoreExists = false, int32_t ttl = TSDB_DEFAULT_TABLE_TTL,
const char* pComment = nullptr) {
SVCreateTbReq req = {0};
req.name = strdup(pName);
req.name = taosStrdup(pName);
if (ignoreExists) {
req.flags |= TD_CREATE_IF_NOT_EXISTS;
}
req.ttl = ttl;
if (nullptr != pComment) {
req.comment = strdup(pComment);
req.comment = taosStrdup(pComment);
req.commentLen = strlen(pComment);
}
++expect.nReqs;

View File

@ -420,7 +420,7 @@ end:
cJSON_Delete(json);
taosArrayDestroy(pTagVals);
if (string == NULL) {
string = strdup(TSDB_DATA_NULL_STR_L);
string = taosStrdup(TSDB_DATA_NULL_STR_L);
}
return string;
}
@ -510,20 +510,20 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) {
(*pDst)->flags = pSrc->flags;
if (pSrc->name) {
(*pDst)->name = strdup(pSrc->name);
(*pDst)->name = taosStrdup(pSrc->name);
}
(*pDst)->uid = pSrc->uid;
(*pDst)->ctime = pSrc->ctime;
(*pDst)->ttl = pSrc->ttl;
(*pDst)->commentLen = pSrc->commentLen;
if (pSrc->comment) {
(*pDst)->comment = strdup(pSrc->comment);
(*pDst)->comment = taosStrdup(pSrc->comment);
}
(*pDst)->type = pSrc->type;
if (pSrc->type == TSDB_CHILD_TABLE) {
if (pSrc->ctb.stbName) {
(*pDst)->ctb.stbName = strdup(pSrc->ctb.stbName);
(*pDst)->ctb.stbName = taosStrdup(pSrc->ctb.stbName);
}
(*pDst)->ctb.tagNum = pSrc->ctb.tagNum;
(*pDst)->ctb.suid = pSrc->ctb.suid;

View File

@ -527,7 +527,7 @@ int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
return code;
}
*(char **)output = strdup(out.ver);
*(char **)output = taosStrdup(out.ver);
return code;
}

View File

@ -716,7 +716,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) {
pJob->attr.localExec = pReq->localReq;
pJob->conn = *pReq->pConn;
if (pReq->sql) {
pJob->sql = strdup(pReq->sql);
pJob->sql = taosStrdup(pReq->sql);
}
pJob->pDag = pReq->pDag;
pJob->allocatorRefId = nodesMakeAllocatorWeakRef(pReq->allocatorRefId);

View File

@ -887,7 +887,7 @@ int32_t schUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, SQueryNodeAddr *addr
} else {
pMsgSendInfo->target.type = TARGET_TYPE_VNODE;
pMsgSendInfo->target.vgId = addr->nodeId;
pMsgSendInfo->target.dbFName = strdup(pTask->plan->dbFName);
pMsgSendInfo->target.dbFName = taosStrdup(pTask->plan->dbFName);
}
return TSDB_CODE_SUCCESS;

View File

@ -26,7 +26,7 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
int32_t len = strlen(path) + 20;
char* streamPath = taosMemoryCalloc(1, len);
sprintf(streamPath, "%s/%s", path, "stream");
pMeta->path = strdup(streamPath);
pMeta->path = taosStrdup(streamPath);
if (tdbOpen(pMeta->path, 16 * 1024, 1, &pMeta->db, 0) < 0) {
taosMemoryFree(streamPath);
goto _err;

View File

@ -240,7 +240,7 @@ int32_t tfsMkdirRecurAt(STfs *pTfs, const char *rname, SDiskID diskId) {
if (tfsMkdirAt(pTfs, rname, diskId) < 0) {
if (errno == ENOENT) {
// Try to create upper
char *s = strdup(rname);
char *s = taosStrdup(rname);
// Make a copy of dirname(s) because the implementation of 'dirname' differs on different platforms.
// Some platform may modify the contents of the string passed into dirname(). Others may return a pointer to
@ -248,7 +248,7 @@ int32_t tfsMkdirRecurAt(STfs *pTfs, const char *rname, SDiskID diskId) {
// the pointer directly in this recursion.
// See
// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dirname.3.html
char *dir = strdup(taosDirName(s));
char *dir = taosStrdup(taosDirName(s));
if (tfsMkdirRecurAt(pTfs, dir, diskId) < 0) {
taosMemoryFree(s);

View File

@ -23,7 +23,7 @@ STfsDisk *tfsNewDisk(int32_t level, int32_t id, const char *path) {
return NULL;
}
pDisk->path = strdup(path);
pDisk->path = taosStrdup(path);
if (pDisk->path == NULL) {
taosMemoryFree(pDisk);
terrno = TSDB_CODE_OUT_OF_MEMORY;

View File

@ -298,8 +298,8 @@ int32_t httpSendQuit() {
static int32_t taosSendHttpReportImpl(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen,
EHttpCompFlag flag) {
SHttpMsg* msg = taosMemoryMalloc(sizeof(SHttpMsg));
msg->server = strdup(server);
msg->uri = strdup(uri);
msg->server = taosStrdup(server);
msg->uri = taosStrdup(uri);
msg->port = port;
msg->cont = taosMemoryMalloc(contLen);
memcpy(msg->cont, pCont, contLen);

View File

@ -1014,7 +1014,7 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) {
if (conn == NULL) {
conn = cliCreateConn(pThrd);
conn->pBatch = pBatch;
conn->ip = strdup(pList->dst);
conn->ip = taosStrdup(pList->dst);
uint32_t ipaddr = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, pList->ip);
if (ipaddr == 0xffffffff) {
@ -1391,7 +1391,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
uint16_t port = EPSET_GET_INUSE_PORT(&pCtx->epSet);
CONN_CONSTRUCT_HASH_KEY(key, fqdn, port);
conn->ip = strdup(key);
conn->ip = taosStrdup(key);
uint32_t ipaddr = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, fqdn);
if (ipaddr == 0xffffffff) {
@ -1503,8 +1503,8 @@ static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) {
pBatchList->batchLenLimit = pInst->batchSize;
pBatchList->len += 1;
pBatchList->ip = strdup(ip);
pBatchList->dst = strdup(key);
pBatchList->ip = taosStrdup(ip);
pBatchList->dst = taosStrdup(key);
pBatchList->port = port;
SCliBatch* pBatch = taosMemoryCalloc(1, sizeof(SCliBatch));

View File

@ -151,7 +151,7 @@ TdFilePtr taosCreateFile(const char *path, int32_t tdFileOptions) {
if (!fp) {
if (errno == ENOENT) {
// Try to create directory recursively
char *s = strdup(path);
char *s = taosStrdup(path);
if (taosMulMkDir(taosDirName(s)) != 0) {
taosMemoryFree(s);
return NULL;

View File

@ -59,11 +59,11 @@ char *taosCharsetReplace(char *charsetstr) {
for (int32_t i = 0; i < tListLen(charsetRep); ++i) {
if (strcasecmp(charsetRep[i].oldCharset, charsetstr) == 0) {
return strdup(charsetRep[i].newCharset);
return taosStrdup(charsetRep[i].newCharset);
}
}
return strdup(charsetstr);
return taosStrdup(charsetstr);
}
/**

View File

@ -87,7 +87,7 @@ void taosPrintBackTrace() {
}
#endif
#else
#define tstrdup(str) strdup(str)
#define tstrdup(str) taosStrdup(str)
#include <execinfo.h>
@ -312,7 +312,7 @@ void *taosMemoryRealloc(void *ptr, int64_t size) {
#endif
}
void *taosMemoryStrDup(const char *ptr) {
void *taosStrdup(const char *ptr) {
#ifdef USE_TD_MEMORY
if (ptr == NULL) return NULL;

View File

@ -391,7 +391,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInMs, bool extendLi
return NULL;
}
pCacheObj->name = strdup(cacheName);
pCacheObj->name = taosStrdup(cacheName);
doRegisterCacheObj(pCacheObj);
return pCacheObj;
}

View File

@ -109,7 +109,7 @@ int32_t cfgGetSize(SConfig *pCfg) { return taosArrayGetSize(pCfg->array); }
static int32_t cfgCheckAndSetTimezone(SConfigItem *pItem, const char *timezone) {
cfgFreeItem(pItem);
pItem->str = strdup(timezone);
pItem->str = taosStrdup(timezone);
if (pItem->str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
@ -120,7 +120,7 @@ static int32_t cfgCheckAndSetTimezone(SConfigItem *pItem, const char *timezone)
static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) {
cfgFreeItem(pItem);
pItem->str = strdup(charset);
pItem->str = taosStrdup(charset);
if (pItem->str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
@ -131,7 +131,7 @@ static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) {
static int32_t cfgCheckAndSetLocale(SConfigItem *pItem, const char *locale) {
cfgFreeItem(pItem);
pItem->str = strdup(locale);
pItem->str = taosStrdup(locale);
if (pItem->str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
@ -149,7 +149,7 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
}
taosMemoryFreeClear(pItem->str);
pItem->str = strdup(fullDir);
pItem->str = taosStrdup(fullDir);
if (pItem->str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
@ -215,7 +215,7 @@ static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType st
}
static int32_t cfgSetString(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
char *tmp = strdup(value);
char *tmp = taosStrdup(value);
if (tmp == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s", pItem->name, cfgDtypeStr(pItem->dtype),
@ -358,7 +358,7 @@ SConfigItem *cfgGetItem(SConfig *pCfg, const char *name) {
static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) {
pItem->stype = CFG_STYPE_DEFAULT;
pItem->name = strdup(name);
pItem->name = taosStrdup(name);
if (pItem->name == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
@ -417,7 +417,7 @@ int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, double mi
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, bool tsc) {
SConfigItem item = {.dtype = CFG_DTYPE_STRING, .tsc = tsc};
item.str = strdup(defaultVal);
item.str = taosStrdup(defaultVal);
if (item.str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;

View File

@ -192,7 +192,7 @@ int32_t tjsonDupStringValue(const SJson* pJson, const char* pName, char** pVal)
if (NULL == p) {
return TSDB_CODE_SUCCESS;
}
*pVal = strdup(p);
*pVal = taosStrdup(p);
return TSDB_CODE_SUCCESS;
}

View File

@ -55,7 +55,7 @@ static int32_t createDiskFile(SDiskbasedBuf* pBuf) {
if (pBuf->path == NULL) { // prepare the file name when needed it
char path[PATH_MAX] = {0};
taosGetTmpfilePath(pBuf->prefix, "paged-buf", path);
pBuf->path = taosMemoryStrDup(path);
pBuf->path = taosStrdup(path);
if (pBuf->path == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@ -351,7 +351,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
pPBuf->totalBufSize = 0;
pPBuf->allocateId = -1;
pPBuf->pFile = NULL;
pPBuf->id = strdup(id);
pPBuf->id = taosStrdup(id);
pPBuf->fileSize = 0;
pPBuf->pFree = taosArrayInit(4, sizeof(SFreeListItem));
pPBuf->freePgList = tdListNew(POINTER_BYTES);

View File

@ -911,7 +911,7 @@ char* matchNextPrefix(STire* tire, char* pre) {
if (cursorVar == -1) {
// first
cursorVar = 0;
return strdup(match->head->word);
return taosStrdup(match->head->word);
}
// according to cursorVar , calculate next one
@ -927,7 +927,7 @@ char* matchNextPrefix(STire* tire, char* pre) {
cursorVar = i;
}
return strdup(item->word);
return taosStrdup(item->word);
}
// check end item
@ -935,7 +935,7 @@ char* matchNextPrefix(STire* tire, char* pre) {
// if cursorVar > var list count, return last and reset cursorVar
cursorVar = -1;
return strdup(item->word);
return taosStrdup(item->word);
}
// move next
@ -1536,7 +1536,7 @@ bool matchSelectQuery(TAOS* con, SShellCmd* cmd) {
// if is input create fields or tags area, return true
bool isCreateFieldsArea(char* p) {
// put to while, support like create table st(ts timestamp, bin1 binary(16), bin2 + blank + TAB
char* p1 = strdup(p);
char* p1 = taosStrdup(p);
bool ret = false;
while (1) {
char* left = strrchr(p1, '(');

View File

@ -127,7 +127,7 @@ void shellRecordCommandToHistory(char *command) {
if (pHistory->hist[pHistory->hend] != NULL) {
taosMemoryFreeClear(pHistory->hist[pHistory->hend]);
}
pHistory->hist[pHistory->hend] = strdup(command);
pHistory->hist[pHistory->hend] = taosStrdup(command);
pHistory->hend = (pHistory->hend + 1) % SHELL_MAX_HISTORY_SIZE;
if (pHistory->hend == pHistory->hstart) {
@ -821,7 +821,7 @@ void shellReadHistory() {
while ((read_size = taosGetsFile(pFile, TSDB_MAX_ALLOWED_SQL_LEN, line)) != -1) {
line[read_size - 1] = '\0';
taosMemoryFree(pHistory->hist[pHistory->hend]);
pHistory->hist[pHistory->hend] = strdup(line);
pHistory->hist[pHistory->hend] = taosStrdup(line);
pHistory->hend = (pHistory->hend + 1) % SHELL_MAX_HISTORY_SIZE;
@ -1105,7 +1105,7 @@ int32_t shellExecute() {
if (runOnce) {
if (pArgs->commands != NULL) {
printf("%s%s\r\n", shell.info.promptHeader, pArgs->commands);
char *cmd = strdup(pArgs->commands);
char *cmd = taosStrdup(pArgs->commands);
shellRunCommand(cmd, true);
taosMemoryFree(cmd);
}

View File

@ -75,7 +75,7 @@ void freeTire(STire* tire) {
// insert a new word to list
bool insertToList(STire* tire, char* word) {
StrName* p = (StrName*)taosMemoryMalloc(sizeof(StrName));
p->name = strdup(word);
p->name = taosStrdup(word);
p->next = NULL;
if (tire->head == NULL) {
@ -218,7 +218,7 @@ void addWordToMatch(SMatch* match, char* word) {
// malloc new
SMatchNode* node = (SMatchNode*)taosMemoryMalloc(sizeof(SMatchNode));
memset(node, 0, sizeof(SMatchNode));
node->word = strdup(word);
node->word = taosStrdup(word);
// append to match
if (match->head == NULL) {