check function return code

This commit is contained in:
yihaoDeng 2024-08-27 14:17:30 +08:00
parent e3a2321ce4
commit 9e25d22f47
1 changed files with 38 additions and 11 deletions

View File

@ -62,7 +62,9 @@ void fstUnFinishedNodesPushEmpty(FstUnFinishedNodes* nodes, bool isFinal) {
node->trans = taosArrayInit(16, sizeof(FstTransition)); node->trans = taosArrayInit(16, sizeof(FstTransition));
FstBuilderNodeUnfinished un = {.node = node, .last = NULL}; FstBuilderNodeUnfinished un = {.node = node, .last = NULL};
(void)taosArrayPush(nodes->stack, &un); if (taosArrayPush(nodes->stack, &un) == NULL) {
fstBuilderNodeDestroy(node);
}
} }
FstBuilderNode* fstUnFinishedNodesPopRoot(FstUnFinishedNodes* nodes) { FstBuilderNode* fstUnFinishedNodesPopRoot(FstUnFinishedNodes* nodes) {
FstBuilderNodeUnfinished* un = taosArrayPop(nodes->stack); FstBuilderNodeUnfinished* un = taosArrayPop(nodes->stack);
@ -120,7 +122,10 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes* nodes, FstSlice bs, Output
FstLastTransition* trn = fstLastTransitionCreate(data[i], 0); FstLastTransition* trn = fstLastTransitionCreate(data[i], 0);
FstBuilderNodeUnfinished un = {.node = n, .last = trn}; FstBuilderNodeUnfinished un = {.node = n, .last = trn};
(void)taosArrayPush(nodes->stack, &un); if (taosArrayPush(nodes->stack, &un) == NULL) {
fstBuilderNodeDestroy(n);
taosMemoryFree(trn);
}
} }
fstUnFinishedNodesPushEmpty(nodes, true); fstUnFinishedNodesPushEmpty(nodes, true);
} }
@ -892,7 +897,9 @@ void fstBuilderNodeUnfinishedLastCompiled(FstBuilderNodeUnfinished* unNode, Comp
return; return;
} }
FstTransition t = {.inp = trn->inp, .out = trn->out, .addr = addr}; FstTransition t = {.inp = trn->inp, .out = trn->out, .addr = addr};
(void)taosArrayPush(unNode->node->trans, &t); if (taosArrayPush(unNode->node->trans, &t) == NULL) {
return;
}
fstLastTransitionDestroy(trn); fstLastTransitionDestroy(trn);
unNode->last = NULL; unNode->last = NULL;
return; return;
@ -1194,12 +1201,16 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
(void)fstNodeGetTransitionAt(node, res, &trn); (void)fstNodeGetTransitionAt(node, res, &trn);
void* preState = autState; void* preState = autState;
autState = automFuncs[aut->type].accept(aut, preState, b); autState = automFuncs[aut->type].accept(aut, preState, b);
(void)taosArrayPush(sws->inp, &b); if (taosArrayPush(sws->inp, &b) == NULL) {
return false;
}
FstStreamState s = {.node = node, .trans = res + 1, .out = {.null = false, .out = out}, .autState = preState}; FstStreamState s = {.node = node, .trans = res + 1, .out = {.null = false, .out = out}, .autState = preState};
node = NULL; node = NULL;
(void)taosArrayPush(sws->stack, &s); if (taosArrayPush(sws->stack, &s) == NULL) {
return false;
}
out += trn.out; out += trn.out;
node = fstGetNode(sws->fst, trn.addr); node = fstGetNode(sws->fst, trn.addr);
} else { } else {
@ -1218,7 +1229,9 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
} }
FstStreamState s = {.node = node, .trans = i, .out = {.null = false, .out = out}, .autState = autState}; FstStreamState s = {.node = node, .trans = i, .out = {.null = false, .out = out}, .autState = autState};
(void)taosArrayPush(sws->stack, &s); if (taosArrayPush(sws->stack, &s) == NULL) {
return false;
}
taosMemoryFree(trans); taosMemoryFree(trans);
return true; return true;
} }
@ -1239,7 +1252,9 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) {
(void)fstNodeGetTransitionAt(n, trans - 1, &trn); (void)fstNodeGetTransitionAt(n, trans - 1, &trn);
FstStreamState s = { FstStreamState s = {
.node = fstGetNode(sws->fst, trn.addr), .trans = 0, .out = {.null = false, .out = out}, .autState = autState}; .node = fstGetNode(sws->fst, trn.addr), .trans = 0, .out = {.null = false, .out = out}, .autState = autState};
(void)taosArrayPush(sws->stack, &s); if (taosArrayPush(sws->stack, &s) == NULL) {
return false;
}
return true; return true;
} }
return false; return false;
@ -1282,8 +1297,14 @@ FStmStRslt* stmStNextWith(FStmSt* sws, streamCallback__fn callback) {
bool isMatch = automFuncs[aut->type].isMatch(aut, nextState); bool isMatch = automFuncs[aut->type].isMatch(aut, nextState);
FstNode* nextNode = fstGetNode(sws->fst, trn.addr); FstNode* nextNode = fstGetNode(sws->fst, trn.addr);
(void)taosArrayPush(nodes, &nextNode); if (taosArrayPush(nodes, &nextNode) == NULL) {
(void)taosArrayPush(sws->inp, &(trn.inp)); taosArrayDestroy(nodes);
return NULL;
}
if (taosArrayPush(sws->inp, &(trn.inp)) == NULL) {
taosArrayDestroy(nodes);
return NULL;
}
if (FST_NODE_IS_FINAL(nextNode)) { if (FST_NODE_IS_FINAL(nextNode)) {
void* eofState = automFuncs[aut->type].acceptEof(aut, nextState); void* eofState = automFuncs[aut->type].acceptEof(aut, nextState);
@ -1292,10 +1313,16 @@ FStmStRslt* stmStNextWith(FStmSt* sws, streamCallback__fn callback) {
} }
} }
FstStreamState s1 = {.node = p->node, .trans = p->trans + 1, .out = p->out, .autState = p->autState}; FstStreamState s1 = {.node = p->node, .trans = p->trans + 1, .out = p->out, .autState = p->autState};
(void)taosArrayPush(sws->stack, &s1); if (taosArrayPush(sws->stack, &s1) == NULL) {
taosArrayDestroy(nodes);
return NULL;
}
FstStreamState s2 = {.node = nextNode, .trans = 0, .out = {.null = false, .out = out}, .autState = nextState}; FstStreamState s2 = {.node = nextNode, .trans = 0, .out = {.null = false, .out = out}, .autState = nextState};
(void)taosArrayPush(sws->stack, &s2); if (taosArrayPush(sws->stack, &s2) == NULL) {
taosArrayDestroy(nodes);
return NULL;
}
int32_t isz = taosArrayGetSize(sws->inp); int32_t isz = taosArrayGetSize(sws->inp);
uint8_t* buf = (uint8_t*)taosMemoryMalloc(isz * sizeof(uint8_t)); uint8_t* buf = (uint8_t*)taosMemoryMalloc(isz * sizeof(uint8_t));