diff --git a/src/tsdb/inc/tsdb.h b/src/inc/tsdb.h similarity index 100% rename from src/tsdb/inc/tsdb.h rename to src/inc/tsdb.h diff --git a/src/util/src/talgo.c b/src/util/src/talgo.c index 7a682cd466adaadd39cf38190725ff8ace7ba2ce..76de87e67d5ef295a75976fa8c85e39d61f16006 100644 --- a/src/util/src/talgo.c +++ b/src/util/src/talgo.c @@ -168,6 +168,7 @@ void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, if (flags == TD_EQ) { return bsearch(key, base, nmemb, size, compar); } else if (flags == TD_GE) { + if (nmemb <= 0) return NULL; if ((*compar)(key, elePtrAt(base, size, 0)) <= 0) return elePtrAt(base, size, 0); if ((*compar)(key, elePtrAt(base, size, nmemb - 1)) > 0) return NULL; @@ -193,6 +194,7 @@ void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, } } } else if (flags == TD_LE) { + if (nmemb <= 0) return NULL; if ((*compar)(key, elePtrAt(base, size, nmemb - 1)) >= 0) return elePtrAt(base, size, nmemb - 1); if ((*compar)(key, elePtrAt(base, size, 0)) < 0) return NULL;