check return code
This commit is contained in:
parent
9e681a2da1
commit
93ecc3a6c4
|
@ -315,6 +315,10 @@ SIndexMultiTermQuery* indexMultiTermQueryCreate(EIndexOperatorType opera) {
|
|||
}
|
||||
mtq->opera = opera;
|
||||
mtq->query = taosArrayInit(4, sizeof(SIndexTermQuery));
|
||||
if (mtq->query == NULL) {
|
||||
taosMemoryFree(mtq);
|
||||
return NULL;
|
||||
}
|
||||
return mtq;
|
||||
}
|
||||
void indexMultiTermQueryDestroy(SIndexMultiTermQuery* pQuery) {
|
||||
|
@ -359,10 +363,22 @@ SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn oper, uint8_t colTy
|
|||
len = idxConvertDataToStr((void*)colVal, IDX_TYPE_GET_TYPE(colType), (void**)&buf);
|
||||
} else if (colVal == NULL) {
|
||||
buf = strndup(INDEX_DATA_NULL_STR, (int32_t)strlen(INDEX_DATA_NULL_STR));
|
||||
if (buf == NULL) {
|
||||
taosMemoryFree(tm->colName);
|
||||
taosMemoryFree(tm);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
len = (int32_t)strlen(INDEX_DATA_NULL_STR);
|
||||
} else {
|
||||
static const char* emptyStr = " ";
|
||||
buf = strndup(emptyStr, (int32_t)strlen(emptyStr));
|
||||
if (buf == NULL) {
|
||||
taosMemoryFree(tm->colName);
|
||||
taosMemoryFree(tm);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL
|
||||
}
|
||||
len = (int32_t)strlen(emptyStr);
|
||||
}
|
||||
|
||||
|
|
|
@ -836,6 +836,7 @@ static MemTable* idxInternalCacheCreate(int8_t type) {
|
|||
IDX_TYPE_CONTAIN_EXTERN_TYPE(type, TSDB_DATA_TYPE_JSON) ? idxCacheJsonTermCompare : idxCacheTermCompare;
|
||||
|
||||
MemTable* tbl = taosMemoryCalloc(1, sizeof(MemTable));
|
||||
if (tbl == NULL) return NULL;
|
||||
idxMemRef(tbl);
|
||||
// if (ttype == TSDB_DATA_TYPE_BINARY || ttype == TSDB_DATA_TYPE_NCHAR || ttype == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
tbl->mem = tSkipListCreate(MAX_SKIP_LIST_LEVEL, ttype, MAX_INDEX_KEY_LEN, cmpFn, SL_ALLOW_DUP_KEY, idxCacheTermGet);
|
||||
|
|
|
@ -389,6 +389,9 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) {
|
|||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
*dst = taosMemoryCalloc(1, bufSize + 1);
|
||||
if (*dst == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
TAOS_UNUSED(idxInt2str(*(uint16_t*)src, *dst, -1));
|
||||
tlen = strlen(*dst);
|
||||
break;
|
||||
|
|
|
@ -1157,11 +1157,20 @@ FStmSt* stmStCreate(Fst* fst, FAutoCtx* automation, FstBoundWithData* min, FstBo
|
|||
sws->fst = fst;
|
||||
sws->aut = automation;
|
||||
sws->inp = (SArray*)taosArrayInit(256, sizeof(uint8_t));
|
||||
if (sws->inp == NULL) {
|
||||
taosMemoryFree(sws);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sws->emptyOutput.null = true;
|
||||
sws->emptyOutput.out = 0;
|
||||
|
||||
sws->stack = (SArray*)taosArrayInit(256, sizeof(FstStreamState));
|
||||
if (sws->stack == NULL) {
|
||||
taosArrayDestroy(sws->inp);
|
||||
taosMemoryFree(sws);
|
||||
return NULL;
|
||||
}
|
||||
sws->endAt = max;
|
||||
TAOS_UNUSED(stmStSeekMin(sws, min));
|
||||
|
||||
|
|
|
@ -120,6 +120,8 @@ FstRegistryEntry* fstRegistryGetEntry(FstRegistry* registry, FstBuilderNode* bNo
|
|||
uint64_t end = start + registry->mruSize;
|
||||
|
||||
FstRegistryEntry* entry = taosMemoryMalloc(sizeof(FstRegistryEntry));
|
||||
if (entry == NULL) return NULL;
|
||||
|
||||
if (end - start == 1) {
|
||||
FstRegistryCell* cell = taosArrayGet(registry->table, start);
|
||||
// cell->isNode &&
|
||||
|
|
|
@ -28,6 +28,12 @@ FstSparseSet *sparSetCreate(int32_t sz) {
|
|||
|
||||
ss->dense = (int32_t *)taosMemoryMalloc(sz * sizeof(int32_t));
|
||||
ss->sparse = (int32_t *)taosMemoryMalloc(sz * sizeof(int32_t));
|
||||
if (ss->dense == NULL || ss->sparse == NULL) {
|
||||
taosMemoryFree(ss->dense);
|
||||
taosMemoryFree(ss->sparse);
|
||||
taosMemoryFree(ss);
|
||||
return NULL;
|
||||
}
|
||||
sparSetInitBuf(ss->dense, sz);
|
||||
sparSetInitBuf(ss->sparse, sz);
|
||||
|
||||
|
|
|
@ -77,10 +77,13 @@ CompiledAddr unpackDelta(char* data, uint64_t len, uint64_t nodeAddr) {
|
|||
|
||||
FstSlice fstSliceCreate(uint8_t* data, uint64_t len) {
|
||||
FstString* str = (FstString*)taosMemoryMalloc(sizeof(FstString));
|
||||
if (str == NULL) {
|
||||
return (FstSlice){.str = NULL, .start = 0, .end = 0};
|
||||
}
|
||||
str->ref = 1;
|
||||
str->len = len;
|
||||
str->data = taosMemoryMalloc(len * sizeof(uint8_t));
|
||||
if (str == NULL || str->data == NULL) {
|
||||
if (str->data == NULL) {
|
||||
taosMemoryFree(str);
|
||||
return (FstSlice){.str = NULL, .start = 0, .end = 0};
|
||||
}
|
||||
|
@ -107,9 +110,16 @@ FstSlice fstSliceDeepCopy(FstSlice* s, int32_t start, int32_t end) {
|
|||
uint8_t* data = fstSliceData(s, &slen);
|
||||
|
||||
uint8_t* buf = taosMemoryMalloc(sizeof(uint8_t) * tlen);
|
||||
if (buf == NULL) {
|
||||
return (FstSlice){.str = NULL, .start = 0, .end = 0};
|
||||
}
|
||||
memcpy(buf, data + start, tlen);
|
||||
|
||||
FstString* str = taosMemoryMalloc(sizeof(FstString));
|
||||
if (str == NULL) {
|
||||
taosMemoryFree(buf);
|
||||
return (FstSlice){.str = NULL, .start = 0, .end = 0};
|
||||
}
|
||||
str->data = buf;
|
||||
str->len = tlen;
|
||||
str->ref = 1;
|
||||
|
|
|
@ -266,16 +266,23 @@ static int32_t httpCreateMsg(const char* server, const char* uri, uint16_t port,
|
|||
msg->server = taosStrdup(server);
|
||||
msg->uri = taosStrdup(uri);
|
||||
msg->cont = taosMemoryMalloc(contLen);
|
||||
if (qid != NULL)
|
||||
msg->qid = taosStrdup(qid);
|
||||
else
|
||||
msg->qid = NULL;
|
||||
if (msg->server == NULL || msg->uri == NULL || msg->cont == NULL) {
|
||||
httpDestroyMsg(msg);
|
||||
*httpMsg = NULL;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (qid != NULL) {
|
||||
msg->qid = taosStrdup(qid);
|
||||
if (msg->qid == NULL) {
|
||||
httpDestroyMsg(msg);
|
||||
*httpMsg = NULL;
|
||||
return terrno;
|
||||
}
|
||||
} else {
|
||||
msg->qid = NULL;
|
||||
}
|
||||
|
||||
memcpy(msg->cont, pCont, contLen);
|
||||
msg->len = contLen;
|
||||
msg->flag = flag;
|
||||
|
|
|
@ -667,6 +667,10 @@ static SCliConn* getConnFromPool(SCliThrd* pThrd, char* key, bool* exceed) {
|
|||
plist = taosHashGet(pool, key, klen);
|
||||
|
||||
SMsgList* nList = taosMemoryCalloc(1, sizeof(SMsgList));
|
||||
if (nList == NULL) {
|
||||
tError("failed to alloc memory for msg list, reason:%s", tstrerror(terrno));
|
||||
return NULL;
|
||||
}
|
||||
QUEUE_INIT(&nList->msgQ);
|
||||
nList->numOfConn++;
|
||||
|
||||
|
@ -715,7 +719,7 @@ static SCliConn* getConnFromPool2(SCliThrd* pThrd, char* key, SCliMsg** pMsg) {
|
|||
|
||||
SMsgList* nList = taosMemoryCalloc(1, sizeof(SMsgList));
|
||||
if (nList == NULL) {
|
||||
tError("failed to alloc memory for msg list, reason:%s", tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||
tError("failed to alloc memory for msg list, reason:%s", tstrerror(terrno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1300,11 +1304,16 @@ void cliSend(SCliConn* pConn) {
|
|||
uv_timer_t* timer = taosArrayGetSize(pThrd->timerList) > 0 ? *(uv_timer_t**)taosArrayPop(pThrd->timerList) : NULL;
|
||||
if (timer == NULL) {
|
||||
timer = taosMemoryCalloc(1, sizeof(uv_timer_t));
|
||||
if (timer == NULL) {
|
||||
tError("failed to alloc timer since %s", tstrerror(terrno));
|
||||
}
|
||||
tDebug("no available timer, create a timer %p", timer);
|
||||
TAOS_UNUSED(uv_timer_init(pThrd->loop, timer));
|
||||
}
|
||||
timer->data = pConn;
|
||||
pConn->timer = timer;
|
||||
if (timer != NULL) {
|
||||
timer->data = pConn;
|
||||
pConn->timer = timer;
|
||||
}
|
||||
|
||||
tGTrace("%s conn %p start timer for msg:%s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pMsg->msgType));
|
||||
TAOS_UNUSED(uv_timer_start((uv_timer_t*)pConn->timer, cliReadTimeoutCb, TRANS_READ_TIMEOUT, 0));
|
||||
|
@ -2552,6 +2561,10 @@ static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
cliSchedMsgToDebug(pMsg, transLabel(pThrd->pTransInst));
|
||||
|
||||
STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg));
|
||||
if (arg == NULL) {
|
||||
tError("failed to malloc memory, reason:%s", tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||
return;
|
||||
}
|
||||
arg->param1 = pMsg;
|
||||
arg->param2 = pThrd;
|
||||
|
||||
|
|
|
@ -846,6 +846,10 @@ static bool uvRecvReleaseReq(SSvrConn* pConn, STransMsgHead* pHead) {
|
|||
|
||||
STransMsg tmsg = {.code = 0, .info.handle = (void*)pConn, .info.traceId = traceId, .info.ahandle = (void*)0x9527};
|
||||
SSvrMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||
if (srvMsg == NULL) {
|
||||
tError("failed to alloc buf to send release resp since %s", tstrerror(terrno));
|
||||
return true;
|
||||
}
|
||||
srvMsg->msg = tmsg;
|
||||
srvMsg->type = Release;
|
||||
srvMsg->pConn = pConn;
|
||||
|
@ -1410,6 +1414,10 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
|||
|
||||
for (int i = 0; i < srv->numOfThreads; i++) {
|
||||
SWorkThrd* thrd = (SWorkThrd*)taosMemoryCalloc(1, sizeof(SWorkThrd));
|
||||
if (thrd == NULL) {
|
||||
code = terrno;
|
||||
goto End;
|
||||
}
|
||||
thrd->pTransInst = shandle;
|
||||
thrd->quit = false;
|
||||
thrd->pTransInst = shandle;
|
||||
|
@ -1663,6 +1671,10 @@ void destroyWorkThrd(SWorkThrd* pThrd) {
|
|||
}
|
||||
void sendQuitToWorkThrd(SWorkThrd* pThrd) {
|
||||
SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||
if (msg == NULL) {
|
||||
tError("failed to send quit msg to work thread since %s", tstrerror(terrno));
|
||||
return;
|
||||
}
|
||||
msg->type = Quit;
|
||||
tDebug("server send quit msg to work thread");
|
||||
TAOS_UNUSED(transAsyncSend(pThrd->asyncPool, &msg->q));
|
||||
|
|
Loading…
Reference in New Issue