From 9e8d761813e21406665c8d923c93512b74c9a8f3 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 26 Sep 2023 11:08:20 +0800 Subject: [PATCH] more fix --- include/util/tarray2.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/util/tarray2.h b/include/util/tarray2.h index a8d460785f..2e9b0c7cb5 100644 --- a/include/util/tarray2.h +++ b/include/util/tarray2.h @@ -165,7 +165,12 @@ static FORCE_INLINE int32_t tarray2SortInsert(void *arr, const void *elePtr, int #define TARRAY2_FOREACH_PTR_REVERSE(a, ep) \ for (int32_t __i = (a)->size - 1; __i >= 0 && ((ep) = &(a)->data[__i], 1); __i--) -#define TARRAY2_SORT(a, cmp) taosSort((a)->data, (a)->size, sizeof((a)->data[0]), (__compar_fn_t)cmp) +#define TARRAY2_SORT(a, cmp) \ + do { \ + if ((a)->size > 1) { \ + taosSort((a)->data, (a)->size, sizeof((a)->data[0]), (__compar_fn_t)cmp); \ + } \ + } while (0) #ifdef __cplusplus }