From 48872f6c4bf8aac33ec0fcca9afd07133e49b725 Mon Sep 17 00:00:00 2001 From: hzcheng Date: Thu, 16 Apr 2020 18:52:07 +0800 Subject: [PATCH] move header --- src/{tsdb => }/inc/tsdb.h | 0 src/util/src/talgo.c | 2 ++ 2 files changed, 2 insertions(+) rename src/{tsdb => }/inc/tsdb.h (100%) 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 7a682cd466..76de87e67d 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; -- GitLab