提交 bb760de1 编写于 作者: dengyihao's avatar dengyihao

add test case

上级 e77931f1
...@@ -126,7 +126,6 @@ bool dfaBuilderCacheState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *r ...@@ -126,7 +126,6 @@ bool dfaBuilderCacheState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *r
for (int i = 0; i < sparSetLen(set); i++) { for (int i = 0; i < sparSetLen(set); i++) {
int32_t ip; int32_t ip;
if (false == sparSetGet(set, i, &ip)) continue; if (false == sparSetGet(set, i, &ip)) continue;
Inst *inst = taosArrayGet(builder->dfa->insts, ip); Inst *inst = taosArrayGet(builder->dfa->insts, ip);
......
...@@ -22,11 +22,8 @@ FstRegex *regexCreate(const char *str) { ...@@ -22,11 +22,8 @@ FstRegex *regexCreate(const char *str) {
if (regex == NULL) { if (regex == NULL) {
return NULL; return NULL;
} }
int32_t sz = (int32_t)strlen(str);
char *orig = taosMemoryCalloc(1, sz);
memcpy(orig, str, sz);
regex->orig = orig; regex->orig = tstrdup(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));
......
...@@ -52,7 +52,7 @@ bool sparSetAdd(FstSparseSet *ss, int32_t ip, int32_t *idx) { ...@@ -52,7 +52,7 @@ bool sparSetAdd(FstSparseSet *ss, int32_t ip, int32_t *idx) {
if (ss == NULL) { if (ss == NULL) {
return false; return false;
} }
if (ip >= ss->cap) { if (ip >= ss->cap || ip < 0) {
return false; return false;
} }
uint32_t i = ss->size; uint32_t i = ss->size;
...@@ -65,7 +65,7 @@ bool sparSetAdd(FstSparseSet *ss, int32_t ip, int32_t *idx) { ...@@ -65,7 +65,7 @@ bool sparSetAdd(FstSparseSet *ss, int32_t ip, int32_t *idx) {
return true; return true;
} }
bool sparSetGet(FstSparseSet *ss, int32_t idx, int32_t *ip) { bool sparSetGet(FstSparseSet *ss, int32_t idx, int32_t *ip) {
if (idx >= ss->cap || idx >= ss->size) { if (idx >= ss->cap || idx >= ss->size || idx < 0) {
return false; return false;
} }
int32_t val = ss->dense[idx]; int32_t val = ss->dense[idx];
...@@ -75,12 +75,12 @@ bool sparSetGet(FstSparseSet *ss, int32_t idx, int32_t *ip) { ...@@ -75,12 +75,12 @@ bool sparSetGet(FstSparseSet *ss, int32_t idx, int32_t *ip) {
return val == -1 ? false : true; return val == -1 ? false : true;
} }
bool sparSetContains(FstSparseSet *ss, int32_t ip) { bool sparSetContains(FstSparseSet *ss, int32_t ip) {
if (ip >= ss->cap) { if (ip >= ss->cap || ip < 0) {
return false; return false;
} }
int32_t i = ss->sparse[ip]; int32_t i = ss->sparse[ip];
if (i < ss->cap && i < ss->size && ss->dense[i] == ip) { if (i >= 0 && i < ss->cap && i < ss->size && ss->dense[i] == ip) {
return true; return true;
} else { } else {
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册