From 8c35b856c6b4d7b60d786f9e6f79e003d0bb4f03 Mon Sep 17 00:00:00 2001 From: xinsheng Ren <285808407@qq.com> Date: Mon, 26 Dec 2022 18:38:01 +0800 Subject: [PATCH] fix/TS-2297/windows sort use stdlib (#19152) Co-authored-by: facetosea <25808407@qq.com> --- source/os/src/osMath.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/source/os/src/osMath.c b/source/os/src/osMath.c index cd2acac261..dddadd5ff6 100644 --- a/source/os/src/osMath.c +++ b/source/os/src/osMath.c @@ -16,6 +16,7 @@ #define ALLOW_FORBID_FUNC #define _DEFAULT_SOURCE #include "os.h" +#include #ifdef WINDOWS void swapStr(char* j, char* J, int width) { @@ -33,16 +34,5 @@ void swapStr(char* j, char* J, int width) { // todo refactor: 1) move away; 2) use merge sort instead; 3) qsort is not a stable sort actually. void taosSort(void* arr, int64_t sz, int64_t width, __compar_fn_t compar) { -#ifdef WINDOWS - int64_t i, j; - for (i = 0; i < sz - 1; i++) { - for (j = 0; j < sz - 1 - i; j++) { - if (compar((char*)arr + j * width, (char*)arr + (j + 1) * width) > 0.00) { - swapStr((char*)arr + j * width, (char*)arr + (j + 1) * width, width); - } - } - } -#else qsort(arr, sz, width, compar); -#endif }