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 calloc CALLOC_FUNC_TAOS_FORBID
#define realloc REALLOC_FUNC_TAOS_FORBID #define realloc REALLOC_FUNC_TAOS_FORBID
#define free FREE_FUNC_TAOS_FORBID #define free FREE_FUNC_TAOS_FORBID
#define strdup STRDUP_FUNC_TAOS_FORBID
#endif // ifndef ALLOW_FORBID_FUNC #endif // ifndef ALLOW_FORBID_FUNC
#endif // if !defined(WINDOWS) #endif // if !defined(WINDOWS)
@ -38,7 +39,7 @@ int32_t taosMemoryDbgInitRestore();
void *taosMemoryMalloc(int64_t size); void *taosMemoryMalloc(int64_t size);
void *taosMemoryCalloc(int64_t num, int64_t size); void *taosMemoryCalloc(int64_t num, int64_t size);
void *taosMemoryRealloc(void *ptr, int64_t size); void *taosMemoryRealloc(void *ptr, int64_t size);
void *taosMemoryStrDup(const char *ptr); void *taosStrdup(const char *ptr);
void taosMemoryFree(void *ptr); void taosMemoryFree(void *ptr);
int64_t taosMemorySize(void *ptr); int64_t taosMemorySize(void *ptr);
void taosPrintBackTrace(); void taosPrintBackTrace();

View File

@ -758,7 +758,7 @@ static void *hbThreadFunc(void *param) {
pInfo->msgInfo.pData = buf; pInfo->msgInfo.pData = buf;
pInfo->msgInfo.len = tlen; pInfo->msgInfo.len = tlen;
pInfo->msgType = TDMT_MND_HEARTBEAT; pInfo->msgType = TDMT_MND_HEARTBEAT;
pInfo->param = strdup(pAppHbMgr->key); pInfo->param = taosStrdup(pAppHbMgr->key);
pInfo->paramFreeFp = taosMemoryFree; pInfo->paramFreeFp = taosMemoryFree;
pInfo->requestId = generateRequestId(); pInfo->requestId = generateRequestId();
pInfo->requestObjRefId = 0; pInfo->requestObjRefId = 0;
@ -826,7 +826,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
pAppHbMgr->connKeyCnt = 0; pAppHbMgr->connKeyCnt = 0;
pAppHbMgr->reportCnt = 0; pAppHbMgr->reportCnt = 0;
pAppHbMgr->reportBytes = 0; pAppHbMgr->reportBytes = 0;
pAppHbMgr->key = strdup(key); pAppHbMgr->key = taosStrdup(key);
// init app info // init app info
pAppHbMgr->pAppInstInfo = pAppInstInfo; 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) { static char* getClusterKey(const char* user, const char* auth, const char* ip, int32_t port) {
char key[512] = {0}; char key[512] = {0};
snprintf(key, sizeof(key), "%s:%s:%s:%d", user, auth, ip, port); snprintf(key, sizeof(key), "%s:%s:%s:%d", user, auth, ip, port);
return strdup(key); return taosStrdup(key);
} }
bool chkRequestKilled(void* param) { 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) { if (strcmp(key, "td.connect.ip") == 0) {
conf->ip = strdup(value); conf->ip = taosStrdup(value);
return TMQ_CONF_OK; return TMQ_CONF_OK;
} }
if (strcmp(key, "td.connect.user") == 0) { if (strcmp(key, "td.connect.user") == 0) {
conf->user = strdup(value); conf->user = taosStrdup(value);
return TMQ_CONF_OK; return TMQ_CONF_OK;
} }
if (strcmp(key, "td.connect.pass") == 0) { if (strcmp(key, "td.connect.pass") == 0) {
conf->pass = strdup(value); conf->pass = taosStrdup(value);
return TMQ_CONF_OK; return TMQ_CONF_OK;
} }
if (strcmp(key, "td.connect.port") == 0) { 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; return TMQ_CONF_OK;
} }
if (strcmp(key, "td.connect.db") == 0) { if (strcmp(key, "td.connect.db") == 0) {
/*conf->db = strdup(value);*/ /*conf->db = taosStrdup(value);*/
return TMQ_CONF_OK; 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) { int32_t tmq_list_append(tmq_list_t* list, const char* src) {
SArray* container = &list->container; SArray* container = &list->container;
if (src == NULL || src[0] == 0) return -1; if (src == NULL || src[0] == 0) return -1;
char* topic = strdup(src); char* topic = taosStrdup(src);
if (topic[0] != '`') { if (topic[0] != '`') {
strtolower(topic, src); strtolower(topic, src);
} }

View File

@ -185,7 +185,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
pDst->arr = taosArrayInit(num, sizeof(char *)); pDst->arr = taosArrayInit(num, sizeof(char *));
for (size_t i = 0; i < num; i++) { for (size_t i = 0; i < num; i++) {
char *p = (char *)taosArrayGetP(pSrc->arr, i); char *p = (char *)taosArrayGetP(pSrc->arr, i);
char *n = strdup(p); char *n = taosStrdup(p);
taosArrayPush(pDst->arr, &n); taosArrayPush(pDst->arr, &n);
} }
} else if (pSrc->nType == TSDB_DATA_TYPE_VALUE_ARRAY) { } 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->vgVersion = pCfg->vgVersion;
pVnode->refCount = 0; pVnode->refCount = 0;
pVnode->dropped = 0; pVnode->dropped = 0;
pVnode->path = tstrdup(pCfg->path); pVnode->path = taosStrdup(pCfg->path);
pVnode->pImpl = pImpl; pVnode->pImpl = pImpl;
if (pVnode->path == NULL) { if (pVnode->path == NULL) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -552,14 +552,14 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
streamObj.sourceDbUid = pDb->uid; streamObj.sourceDbUid = pDb->uid;
streamObj.targetDbUid = pDb->uid; streamObj.targetDbUid = pDb->uid;
streamObj.version = 1; streamObj.version = 1;
streamObj.sql = strdup(pCreate->sql); streamObj.sql = taosStrdup(pCreate->sql);
streamObj.smaId = smaObj.uid; streamObj.smaId = smaObj.uid;
streamObj.watermark = pCreate->watermark; streamObj.watermark = pCreate->watermark;
streamObj.deleteMark = pCreate->deleteMark; streamObj.deleteMark = pCreate->deleteMark;
streamObj.fillHistory = STREAM_FILL_HISTORY_ON; streamObj.fillHistory = STREAM_FILL_HISTORY_ON;
streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE; streamObj.trigger = STREAM_TRIGGER_WINDOW_CLOSE;
streamObj.triggerParam = pCreate->maxDelay; streamObj.triggerParam = pCreate->maxDelay;
streamObj.ast = strdup(smaObj.ast); streamObj.ast = taosStrdup(smaObj.ast);
// check the maxDelay // check the maxDelay
if (streamObj.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) { 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->ttl = pStb->ttl;
pRsp->commentLen = pStb->commentLen; pRsp->commentLen = pStb->commentLen;
if (pStb->commentLen > 0) { if (pStb->commentLen > 0) {
pRsp->pComment = strdup(pStb->comment); pRsp->pComment = taosStrdup(pStb->comment);
} }
for (int32_t i = 0; i < pStb->numOfColumns; ++i) { 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.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
topicObj.dbUid = pDb->uid; topicObj.dbUid = pDb->uid;
topicObj.version = 1; topicObj.version = 1;
topicObj.sql = strdup(pCreate->sql); topicObj.sql = taosStrdup(pCreate->sql);
topicObj.sqlLen = strlen(pCreate->sql) + 1; topicObj.sqlLen = strlen(pCreate->sql) + 1;
topicObj.subType = pCreate->subType; topicObj.subType = pCreate->subType;
topicObj.withMeta = pCreate->withMeta; topicObj.withMeta = pCreate->withMeta;
@ -392,7 +392,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
} }
if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) { if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) {
topicObj.ast = strdup(pCreate->ast); topicObj.ast = taosStrdup(pCreate->ast);
topicObj.astLen = strlen(pCreate->ast) + 1; topicObj.astLen = strlen(pCreate->ast) + 1;
qDebugL("ast %s", topicObj.ast); qDebugL("ast %s", topicObj.ast);

View File

@ -124,7 +124,7 @@ class MndTestTrans2 : public ::testing::Test {
mndTransAppendUndolog(pTrans, pUndoRaw); mndTransAppendUndolog(pTrans, pUndoRaw);
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED); 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); mndTransSetCb(pTrans, TRANS_START_FUNC_TEST, TRANS_STOP_FUNC_TEST, param, strlen(param) + 1);
if (pDb != NULL) { if (pDb != NULL) {
@ -157,7 +157,7 @@ class MndTestTrans2 : public ::testing::Test {
mndTransAppendUndolog(pTrans, pUndoRaw); mndTransAppendUndolog(pTrans, pUndoRaw);
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED); 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); 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); mndTransAppendUndolog(pTrans, pUndoRaw);
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED); 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); mndTransSetCb(pTrans, TRANS_START_FUNC_TEST, TRANS_STOP_FUNC_TEST, param, strlen(param) + 1);
int32_t code = mndTransPrepare(pMnode, pTrans); int32_t code = mndTransPrepare(pMnode, pTrans);

View File

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

View File

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

View File

@ -252,7 +252,7 @@ static void saveSuperTableInfoForChildTable(SMetaEntry* me, SHashObj* suidInfo)
return; return;
} }
STableInfoForChildTable dataTmp = {0}; STableInfoForChildTable dataTmp = {0};
dataTmp.tableName = strdup(me->name); dataTmp.tableName = taosStrdup(me->name);
dataTmp.schemaRow = tCloneSSchemaWrapper(&me->stbEntry.schemaRow); dataTmp.schemaRow = tCloneSSchemaWrapper(&me->stbEntry.schemaRow);
dataTmp.tagRow = tCloneSSchemaWrapper(&me->stbEntry.schemaTag); 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 // set the backend of stream state
tdRSmaQTaskInfoGetFullPathEx(TD_VID(pVnode), pRSmaInfo->suid, idx + 1, tfsGetPrimaryPath(pVnode->pTfs), taskInfDir); tdRSmaQTaskInfoGetFullPathEx(TD_VID(pVnode), pRSmaInfo->suid, idx + 1, tfsGetPrimaryPath(pVnode->pTfs), taskInfDir);
if (!taosCheckExistFile(taskInfDir)) { if (!taosCheckExistFile(taskInfDir)) {
char *s = strdup(taskInfDir); char *s = taosStrdup(taskInfDir);
if (taosMulMkDir(taosDirName(s)) != 0) { if (taosMulMkDir(taosDirName(s)) != 0) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
taosMemoryFree(s); taosMemoryFree(s);

View File

@ -208,7 +208,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
// set super table name // set super table name
SName name = {0}; SName name = {0};
tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); 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 // set tag content
taosArrayClear(tagArray); taosArrayClear(tagArray);
@ -237,7 +237,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
// set table name // set table name
if (pDataBlock->info.parTbName[0]) { if (pDataBlock->info.parTbName[0]) {
pCreateTbReq->name = strdup(pDataBlock->info.parTbName); pCreateTbReq->name = taosStrdup(pDataBlock->info.parTbName);
} else { } else {
pCreateTbReq->name = buildCtbNameByGroupId(stbFullName, pDataBlock->info.id.groupId); 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; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
pTq->path = strdup(path); pTq->path = taosStrdup(path);
pTq->pVnode = pVnode; pTq->pVnode = pVnode;
pTq->walLogLastVer = pVnode->pWal->vers.lastVer; 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; return -1;
} }
for (int32_t i = 0; i < n; i++) { for (int32_t i = 0; i < n; i++) {
char* tbName = strdup(mr.me.name); char* tbName = taosStrdup(mr.me.name);
taosArrayPush(pRsp->blockTbName, &tbName); taosArrayPush(pRsp->blockTbName, &tbName);
} }
metaReaderClear(&mr); metaReaderClear(&mr);
@ -157,7 +157,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
continue; continue;
} }
} else { } else {
char* tbName = strdup(qExtractTbnameFromTask(task)); char* tbName = taosStrdup(qExtractTbnameFromTask(task));
taosArrayPush(pRsp->blockTbName, &tbName); taosArrayPush(pRsp->blockTbName, &tbName);
} }
} }

View File

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

View File

@ -677,7 +677,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
pReader->order = pCond->order; pReader->order = pCond->order;
pReader->capacity = capacity; pReader->capacity = capacity;
pReader->pResBlock = pResBlock; pReader->pResBlock = pResBlock;
pReader->idStr = (idstr != NULL) ? strdup(idstr) : NULL; pReader->idStr = (idstr != NULL) ? taosStrdup(idstr) : NULL;
pReader->verRange = getQueryVerRange(pVnode, pCond, level); pReader->verRange = getQueryVerRange(pVnode, pCond, level);
pReader->type = pCond->type; pReader->type = pCond->type;
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows); 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.ttl = mer1.me.ctbEntry.ttlDays;
cfgRsp.commentLen = mer1.me.ctbEntry.commentLen; cfgRsp.commentLen = mer1.me.ctbEntry.commentLen;
if (mer1.me.ctbEntry.commentLen > 0) { 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; STag *pTag = (STag *)mer1.me.ctbEntry.pTags;
cfgRsp.tagsLen = pTag->len; cfgRsp.tagsLen = pTag->len;
@ -208,7 +208,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
cfgRsp.ttl = mer1.me.ntbEntry.ttlDays; cfgRsp.ttl = mer1.me.ntbEntry.ttlDays;
cfgRsp.commentLen = mer1.me.ntbEntry.commentLen; cfgRsp.commentLen = mer1.me.ntbEntry.commentLen;
if (mer1.me.ntbEntry.commentLen > 0) { if (mer1.me.ntbEntry.commentLen > 0) {
cfgRsp.pComment = strdup(mer1.me.ntbEntry.comment); cfgRsp.pComment = taosStrdup(mer1.me.ntbEntry.comment);
} }
} else { } else {
ASSERT(0); ASSERT(0);

View File

@ -281,7 +281,7 @@ int32_t ctgdHandleDbgCommand(char *command) {
CTG_RET(TSDB_CODE_INVALID_PARA); CTG_RET(TSDB_CODE_INVALID_PARA);
} }
char *dup = strdup(command); char *dup = taosStrdup(command);
char *option = NULL; char *option = NULL;
char *param = 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->reqType = reqType;
pCtx->out = out; pCtx->out = out;
if (target) { if (target) {
pCtx->target = strdup(target); pCtx->target = taosStrdup(target);
if (NULL == pCtx->target) { if (NULL == pCtx->target) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); 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.reqType = reqType;
ctx.out = out; ctx.out = out;
if (target) { if (target) {
ctx.target = strdup(target); ctx.target = taosStrdup(target);
if (NULL == ctx.target) { if (NULL == ctx.target) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); 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) { for (int32_t i = 0; i < num; ++i) {
STableIndexInfo* pInfo = taosArrayGet(pIndex, i); STableIndexInfo* pInfo = taosArrayGet(pIndex, i);
pInfo = taosArrayPush(*pRes, pInfo); pInfo = taosArrayPush(*pRes, pInfo);
pInfo->expr = strdup(pInfo->expr); pInfo->expr = taosStrdup(pInfo->expr);
} }
return TSDB_CODE_SUCCESS; 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) { if (msgType == TDMT_VND_TABLE_META || msgType == TDMT_VND_TABLE_CFG || msgType == TDMT_VND_BATCH_META) {
pMsgSendInfo->target.type = TARGET_TYPE_VNODE; pMsgSendInfo->target.type = TARGET_TYPE_VNODE;
pMsgSendInfo->target.vgId = vgId; pMsgSendInfo->target.vgId = vgId;
pMsgSendInfo->target.dbFName = strdup(dbFName); pMsgSendInfo->target.dbFName = taosStrdup(dbFName);
} else { } else {
pMsgSendInfo->target.type = TARGET_TYPE_MNODE; pMsgSendInfo->target.type = TARGET_TYPE_MNODE;
} }

View File

@ -1529,7 +1529,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet); fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet);
} else { } else {
char* udfName = pExpr->pExpr->_function.pFunctNode->functionName; char* udfName = pExpr->pExpr->_function.pFunctNode->functionName;
pCtx->udfName = strdup(udfName); pCtx->udfName = taosStrdup(udfName);
fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet); fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet);
} }
pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env); 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); setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
pTaskInfo->schemaInfo.dbname = strdup(dbFName); pTaskInfo->schemaInfo.dbname = taosStrdup(dbFName);
pTaskInfo->execModel = model; pTaskInfo->execModel = model;
pTaskInfo->pTableInfoList = tableListCreate(); pTaskInfo->pTableInfoList = tableListCreate();
pTaskInfo->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo)); pTaskInfo->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo));
@ -2026,7 +2026,7 @@ int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode,
} }
SSchemaInfo* pSchemaInfo = &pTaskInfo->schemaInfo; SSchemaInfo* pSchemaInfo = &pTaskInfo->schemaInfo;
pSchemaInfo->tablename = strdup(mr.me.name); pSchemaInfo->tablename = taosStrdup(mr.me.name);
if (mr.me.type == TSDB_SUPER_TABLE) { if (mr.me.type == TSDB_SUPER_TABLE) {
pSchemaInfo->sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow); pSchemaInfo->sw = tCloneSSchemaWrapper(&mr.me.stbEntry.schemaRow);

View File

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

View File

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

View File

@ -90,7 +90,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
tsortSetComparFp(pSortHandle, msortComparFn); tsortSetComparFp(pSortHandle, msortComparFn);
if (idstr != NULL) { if (idstr != NULL) {
pSortHandle->idStr = strdup(idstr); pSortHandle->idStr = taosStrdup(idstr);
} }
return pSortHandle; 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->colObj = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
idx->version = 1; idx->version = 1;
idx->path = tstrdup(path); idx->path = taosStrdup(path);
taosThreadMutexInit(&idx->mtx, NULL); taosThreadMutexInit(&idx->mtx, NULL);
tsem_init(&idx->sem, 0, 0); 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 = idxInternalCacheCreate(type);
cache->mem->pCache = cache; 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->type = type;
cache->index = idx; cache->index = idx;
cache->version = 0; cache->version = 0;
@ -767,7 +767,7 @@ static bool idxCacheIteratorNext(Iterate* itera) {
iv->type = ct->operaType; iv->type = ct->operaType;
iv->ver = ct->version; iv->ver = ct->version;
iv->colVal = tstrdup(ct->colVal); iv->colVal = taosStrdup(ct->colVal);
taosArrayPush(iv->val, &ct->uid); taosArrayPush(iv->val, &ct->uid);
} }
return next; return next;

View File

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

View File

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

View File

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

View File

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

View File

@ -40,7 +40,7 @@
if (NULL == (pSrc)->fldname) { \ if (NULL == (pSrc)->fldname) { \
break; \ break; \
} \ } \
(pDst)->fldname = strdup((pSrc)->fldname); \ (pDst)->fldname = taosStrdup((pSrc)->fldname); \
if (NULL == (pDst)->fldname) { \ if (NULL == (pDst)->fldname) { \
return TSDB_CODE_OUT_OF_MEMORY; \ 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); SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
string tmp = to_string(stoi(((SValueNode*)(pOp->pLeft))->literal) + stoi(((SValueNode*)(pOp->pRight))->literal)); 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); nodesDestroyNode(*pNode);
*pNode = (SNode*)pVal; *pNode = (SNode*)pVal;
} }
@ -40,12 +40,12 @@ TEST(NodesTest, traverseTest) {
SOperatorNode* pOp = (SOperatorNode*)pRoot; SOperatorNode* pOp = (SOperatorNode*)pRoot;
SOperatorNode* pLeft = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR); SOperatorNode* pLeft = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
pLeft->pLeft = (SNode*)nodesMakeNode(QUERY_NODE_VALUE); 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); pLeft->pRight = (SNode*)nodesMakeNode(QUERY_NODE_VALUE);
((SValueNode*)(pLeft->pRight))->literal = strdup("5"); ((SValueNode*)(pLeft->pRight))->literal = taosStrdup("5");
pOp->pLeft = (SNode*)pLeft; pOp->pLeft = (SNode*)pLeft;
pOp->pRight = (SNode*)nodesMakeNode(QUERY_NODE_VALUE); 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); EXPECT_EQ(nodeType(pRoot), QUERY_NODE_OPERATOR);
EDealRes res = DEAL_RES_CONTINUE; EDealRes res = DEAL_RES_CONTINUE;

View File

@ -355,7 +355,7 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
CHECK_OUT_OF_MEM(val); CHECK_OUT_OF_MEM(val);
val->literal = strdup(pCxt->pQueryCxt->db); val->literal = taosStrdup(pCxt->pQueryCxt->db);
CHECK_OUT_OF_MEM(val->literal); CHECK_OUT_OF_MEM(val->literal);
val->isDuration = false; val->isDuration = false;
val->translate = 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) { if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) {
return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name); 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; val->nData = pToken->n;
break; 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, void insBuildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname,
SArray* tagName, uint8_t tagNum, int32_t ttl) { SArray* tagName, uint8_t tagNum, int32_t ttl) {
pTbReq->type = TD_CHILD_TABLE; pTbReq->type = TD_CHILD_TABLE;
pTbReq->name = strdup(tname); pTbReq->name = taosStrdup(tname);
pTbReq->ctb.suid = suid; pTbReq->ctb.suid = suid;
pTbReq->ctb.tagNum = tagNum; 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.pTag = (uint8_t*)pTag;
pTbReq->ctb.tagName = taosArrayDup(tagName, NULL); pTbReq->ctb.tagName = taosArrayDup(tagName, NULL);
pTbReq->ttl = ttl; 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) { static int32_t rewriteDatabaseFunc(STranslateContext* pCxt, SNode** pNode) {
char* pCurrDb = NULL; char* pCurrDb = NULL;
if (NULL != pCxt->pParseCxt->db) { if (NULL != pCxt->pParseCxt->db) {
pCurrDb = taosMemoryStrDup((void*)pCxt->pParseCxt->db); pCurrDb = taosStrdup((void*)pCxt->pParseCxt->db);
if (NULL == pCurrDb) { if (NULL == pCurrDb) {
return TSDB_CODE_OUT_OF_MEMORY; 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) { static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
char* pVer = taosMemoryStrDup((void*)version); char* pVer = taosStrdup((void*)version);
if (NULL == pVer) { if (NULL == pVer) {
return TSDB_CODE_OUT_OF_MEMORY; 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) { 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) { if (NULL == pVer) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -1720,7 +1720,7 @@ static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
if (pCxt->pParseCxt->nodeOffline) { if (pCxt->pParseCxt->nodeOffline) {
return TSDB_CODE_RPC_NETWORK_UNAVAIL; return TSDB_CODE_RPC_NETWORK_UNAVAIL;
} }
char* pStatus = taosMemoryStrDup((void*)"1"); char* pStatus = taosStrdup((void*)"1");
return rewriteFuncToValue(pCxt, pStatus, pNode); 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' char userConn[TSDB_USER_LEN + 1 + TSDB_FQDN_LEN] = {0}; // format 'user@host'
int32_t len = snprintf(userConn, sizeof(userConn), "%s@", pCxt->pParseCxt->pUser); int32_t len = snprintf(userConn, sizeof(userConn), "%s@", pCxt->pParseCxt->pUser);
taosGetFqdn(userConn + len); taosGetFqdn(userConn + len);
char* pUserConn = taosMemoryStrDup((void*)userConn); char* pUserConn = taosStrdup((void*)userConn);
if (NULL == pUserConn) { if (NULL == pUserConn) {
return TSDB_CODE_OUT_OF_MEMORY; 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->numOfColumns = LIST_LENGTH(pStmt->pCols);
pReq->numOfTags = LIST_LENGTH(pStmt->pTags); pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
if (pStmt->pOptions->commentNull == false) { if (pStmt->pOptions->commentNull == false) {
pReq->pComment = strdup(pStmt->pOptions->comment); pReq->pComment = taosStrdup(pStmt->pOptions->comment);
if (NULL == pReq->pComment) { if (NULL == pReq->pComment) {
return TSDB_CODE_OUT_OF_MEMORY; 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) { if (TSDB_ALTER_TABLE_UPDATE_OPTIONS == pStmt->alterType) {
// pAlterReq->ttl = pStmt->pOptions->ttl; // pAlterReq->ttl = pStmt->pOptions->ttl;
if (pStmt->pOptions->commentNull == false) { if (pStmt->pOptions->commentNull == false) {
pAlterReq->comment = strdup(pStmt->pOptions->comment); pAlterReq->comment = taosStrdup(pStmt->pOptions->comment);
if (NULL == pAlterReq->comment) { if (NULL == pAlterReq->comment) {
return TSDB_CODE_OUT_OF_MEMORY; 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) { static int32_t getSmaIndexSql(STranslateContext* pCxt, char** pSql, int32_t* pLen) {
*pSql = strdup(pCxt->pParseCxt->pSql); *pSql = taosStrdup(pCxt->pParseCxt->pSql);
if (NULL == *pSql) { if (NULL == *pSql) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -5505,7 +5505,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
pReq->igExists = pStmt->ignoreExists; pReq->igExists = pStmt->ignoreExists;
pReq->withMeta = pStmt->withMeta; pReq->withMeta = pStmt->withMeta;
pReq->sql = strdup(pCxt->pParseCxt->pSql); pReq->sql = taosStrdup(pCxt->pParseCxt->pSql);
if (NULL == pReq->sql) { if (NULL == pReq->sql) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -6252,7 +6252,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
int32_t code = buildCreateStreamQuery(pCxt, pStmt, pReq); int32_t code = buildCreateStreamQuery(pCxt, pStmt, pReq);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
pReq->sql = strdup(pCxt->pParseCxt->pSql); pReq->sql = taosStrdup(pCxt->pParseCxt->pSql);
if (NULL == pReq->sql) { if (NULL == pReq->sql) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
} }
@ -7144,10 +7144,10 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
SVCreateTbReq req = {0}; SVCreateTbReq req = {0};
req.type = TD_NORMAL_TABLE; req.type = TD_NORMAL_TABLE;
req.name = strdup(pStmt->tableName); req.name = taosStrdup(pStmt->tableName);
req.ttl = pStmt->pOptions->ttl; req.ttl = pStmt->pOptions->ttl;
if (pStmt->pOptions->commentNull == false) { if (pStmt->pOptions->commentNull == false) {
req.comment = strdup(pStmt->pOptions->comment); req.comment = taosStrdup(pStmt->pOptions->comment);
if (NULL == req.comment) { if (NULL == req.comment) {
tdDestroySVCreateTbReq(&req); tdDestroySVCreateTbReq(&req);
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
@ -7306,17 +7306,17 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
struct SVCreateTbReq req = {0}; struct SVCreateTbReq req = {0};
req.type = TD_CHILD_TABLE; req.type = TD_CHILD_TABLE;
req.name = strdup(pStmt->tableName); req.name = taosStrdup(pStmt->tableName);
req.ttl = pStmt->pOptions->ttl; req.ttl = pStmt->pOptions->ttl;
if (pStmt->pOptions->commentNull == false) { if (pStmt->pOptions->commentNull == false) {
req.comment = strdup(pStmt->pOptions->comment); req.comment = taosStrdup(pStmt->pOptions->comment);
req.commentLen = strlen(pStmt->pOptions->comment); req.commentLen = strlen(pStmt->pOptions->comment);
} else { } else {
req.commentLen = -1; req.commentLen = -1;
} }
req.ctb.suid = suid; req.ctb.suid = suid;
req.ctb.tagNum = tagNum; req.ctb.tagNum = tagNum;
req.ctb.stbName = strdup(sTableNmae); req.ctb.stbName = taosStrdup(sTableNmae);
req.ctb.pTag = (uint8_t*)pTag; req.ctb.pTag = (uint8_t*)pTag;
req.ctb.tagName = taosArrayDup(tagName, NULL); req.ctb.tagName = taosArrayDup(tagName, NULL);
if (pStmt->ignoreExists) { if (pStmt->ignoreExists) {
@ -7798,7 +7798,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
pStmt->colName); pStmt->colName);
} }
pReq->tagName = strdup(pStmt->colName); pReq->tagName = taosStrdup(pStmt->colName);
if (NULL == pReq->tagName) { if (NULL == pReq->tagName) {
return TSDB_CODE_OUT_OF_MEMORY; 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); 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) { if (NULL == pReq->colName) {
return TSDB_CODE_OUT_OF_MEMORY; 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); 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) { if (NULL == pReq->colName) {
return TSDB_CODE_OUT_OF_MEMORY; 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); 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) { if (NULL == pReq->colName) {
return TSDB_CODE_OUT_OF_MEMORY; 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); return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DUPLICATED_COLUMN);
} }
pReq->colName = strdup(pStmt->colName); pReq->colName = taosStrdup(pStmt->colName);
pReq->colNewName = strdup(pStmt->newColName); pReq->colNewName = taosStrdup(pStmt->newColName);
if (NULL == pReq->colName || NULL == pReq->colNewName) { if (NULL == pReq->colName || NULL == pReq->colNewName) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -7955,7 +7955,7 @@ static int32_t buildUpdateOptionsReq(STranslateContext* pCxt, SAlterTableStmt* p
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
if (pStmt->pOptions->commentNull == false) { if (pStmt->pOptions->commentNull == false) {
pReq->newComment = strdup(pStmt->pOptions->comment); pReq->newComment = taosStrdup(pStmt->pOptions->comment);
if (NULL == pReq->newComment) { if (NULL == pReq->newComment) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
} else { } else {
@ -7971,7 +7971,7 @@ static int32_t buildUpdateOptionsReq(STranslateContext* pCxt, SAlterTableStmt* p
static int32_t buildAlterTbReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, static int32_t buildAlterTbReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta,
SVAlterTbReq* pReq) { SVAlterTbReq* pReq) {
pReq->tbName = strdup(pStmt->tableName); pReq->tbName = taosStrdup(pStmt->tableName);
if (NULL == pReq->tbName) { if (NULL == pReq->tbName) {
return TSDB_CODE_OUT_OF_MEMORY; 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) { for (int32_t i = 0; i < size; ++i) {
STableIndexInfo* pIndex = taosArrayGet(pDst, 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) { if (NULL == pIndex->expr) {
taosArrayDestroyEx(pDst, destroySmaIndex); taosArrayDestroyEx(pDst, destroySmaIndex);
return NULL; return NULL;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -887,7 +887,7 @@ int32_t schUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, SQueryNodeAddr *addr
} else { } else {
pMsgSendInfo->target.type = TARGET_TYPE_VNODE; pMsgSendInfo->target.type = TARGET_TYPE_VNODE;
pMsgSendInfo->target.vgId = addr->nodeId; pMsgSendInfo->target.vgId = addr->nodeId;
pMsgSendInfo->target.dbFName = strdup(pTask->plan->dbFName); pMsgSendInfo->target.dbFName = taosStrdup(pTask->plan->dbFName);
} }
return TSDB_CODE_SUCCESS; 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; int32_t len = strlen(path) + 20;
char* streamPath = taosMemoryCalloc(1, len); char* streamPath = taosMemoryCalloc(1, len);
sprintf(streamPath, "%s/%s", path, "stream"); 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) { if (tdbOpen(pMeta->path, 16 * 1024, 1, &pMeta->db, 0) < 0) {
taosMemoryFree(streamPath); taosMemoryFree(streamPath);
goto _err; 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 (tfsMkdirAt(pTfs, rname, diskId) < 0) {
if (errno == ENOENT) { if (errno == ENOENT) {
// Try to create upper // 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. // 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 // 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. // the pointer directly in this recursion.
// See // See
// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dirname.3.html // 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) { if (tfsMkdirRecurAt(pTfs, dir, diskId) < 0) {
taosMemoryFree(s); taosMemoryFree(s);

View File

@ -23,7 +23,7 @@ STfsDisk *tfsNewDisk(int32_t level, int32_t id, const char *path) {
return NULL; return NULL;
} }
pDisk->path = strdup(path); pDisk->path = taosStrdup(path);
if (pDisk->path == NULL) { if (pDisk->path == NULL) {
taosMemoryFree(pDisk); taosMemoryFree(pDisk);
terrno = TSDB_CODE_OUT_OF_MEMORY; 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, static int32_t taosSendHttpReportImpl(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen,
EHttpCompFlag flag) { EHttpCompFlag flag) {
SHttpMsg* msg = taosMemoryMalloc(sizeof(SHttpMsg)); SHttpMsg* msg = taosMemoryMalloc(sizeof(SHttpMsg));
msg->server = strdup(server); msg->server = taosStrdup(server);
msg->uri = strdup(uri); msg->uri = taosStrdup(uri);
msg->port = port; msg->port = port;
msg->cont = taosMemoryMalloc(contLen); msg->cont = taosMemoryMalloc(contLen);
memcpy(msg->cont, pCont, contLen); memcpy(msg->cont, pCont, contLen);

View File

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

View File

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

View File

@ -59,11 +59,11 @@ char *taosCharsetReplace(char *charsetstr) {
for (int32_t i = 0; i < tListLen(charsetRep); ++i) { for (int32_t i = 0; i < tListLen(charsetRep); ++i) {
if (strcasecmp(charsetRep[i].oldCharset, charsetstr) == 0) { 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 #endif
#else #else
#define tstrdup(str) strdup(str) #define tstrdup(str) taosStrdup(str)
#include <execinfo.h> #include <execinfo.h>
@ -312,7 +312,7 @@ void *taosMemoryRealloc(void *ptr, int64_t size) {
#endif #endif
} }
void *taosMemoryStrDup(const char *ptr) { void *taosStrdup(const char *ptr) {
#ifdef USE_TD_MEMORY #ifdef USE_TD_MEMORY
if (ptr == NULL) return NULL; if (ptr == NULL) return NULL;

View File

@ -391,7 +391,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInMs, bool extendLi
return NULL; return NULL;
} }
pCacheObj->name = strdup(cacheName); pCacheObj->name = taosStrdup(cacheName);
doRegisterCacheObj(pCacheObj); doRegisterCacheObj(pCacheObj);
return 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) { static int32_t cfgCheckAndSetTimezone(SConfigItem *pItem, const char *timezone) {
cfgFreeItem(pItem); cfgFreeItem(pItem);
pItem->str = strdup(timezone); pItem->str = taosStrdup(timezone);
if (pItem->str == NULL) { if (pItem->str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
@ -120,7 +120,7 @@ static int32_t cfgCheckAndSetTimezone(SConfigItem *pItem, const char *timezone)
static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) { static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) {
cfgFreeItem(pItem); cfgFreeItem(pItem);
pItem->str = strdup(charset); pItem->str = taosStrdup(charset);
if (pItem->str == NULL) { if (pItem->str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
@ -131,7 +131,7 @@ static int32_t cfgCheckAndSetCharset(SConfigItem *pItem, const char *charset) {
static int32_t cfgCheckAndSetLocale(SConfigItem *pItem, const char *locale) { static int32_t cfgCheckAndSetLocale(SConfigItem *pItem, const char *locale) {
cfgFreeItem(pItem); cfgFreeItem(pItem);
pItem->str = strdup(locale); pItem->str = taosStrdup(locale);
if (pItem->str == NULL) { if (pItem->str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
@ -149,7 +149,7 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
} }
taosMemoryFreeClear(pItem->str); taosMemoryFreeClear(pItem->str);
pItem->str = strdup(fullDir); pItem->str = taosStrdup(fullDir);
if (pItem->str == NULL) { if (pItem->str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; 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) { static int32_t cfgSetString(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
char *tmp = strdup(value); char *tmp = taosStrdup(value);
if (tmp == NULL) { if (tmp == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; 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), 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) { static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) {
pItem->stype = CFG_STYPE_DEFAULT; pItem->stype = CFG_STYPE_DEFAULT;
pItem->name = strdup(name); pItem->name = taosStrdup(name);
if (pItem->name == NULL) { if (pItem->name == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; 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) { int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, bool tsc) {
SConfigItem item = {.dtype = CFG_DTYPE_STRING, .tsc = tsc}; SConfigItem item = {.dtype = CFG_DTYPE_STRING, .tsc = tsc};
item.str = strdup(defaultVal); item.str = taosStrdup(defaultVal);
if (item.str == NULL) { if (item.str == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;

View File

@ -192,7 +192,7 @@ int32_t tjsonDupStringValue(const SJson* pJson, const char* pName, char** pVal)
if (NULL == p) { if (NULL == p) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
*pVal = strdup(p); *pVal = taosStrdup(p);
return TSDB_CODE_SUCCESS; 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 if (pBuf->path == NULL) { // prepare the file name when needed it
char path[PATH_MAX] = {0}; char path[PATH_MAX] = {0};
taosGetTmpfilePath(pBuf->prefix, "paged-buf", path); taosGetTmpfilePath(pBuf->prefix, "paged-buf", path);
pBuf->path = taosMemoryStrDup(path); pBuf->path = taosStrdup(path);
if (pBuf->path == NULL) { if (pBuf->path == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; 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->totalBufSize = 0;
pPBuf->allocateId = -1; pPBuf->allocateId = -1;
pPBuf->pFile = NULL; pPBuf->pFile = NULL;
pPBuf->id = strdup(id); pPBuf->id = taosStrdup(id);
pPBuf->fileSize = 0; pPBuf->fileSize = 0;
pPBuf->pFree = taosArrayInit(4, sizeof(SFreeListItem)); pPBuf->pFree = taosArrayInit(4, sizeof(SFreeListItem));
pPBuf->freePgList = tdListNew(POINTER_BYTES); pPBuf->freePgList = tdListNew(POINTER_BYTES);

View File

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

View File

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

View File

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