From 925276e44921407cec3f7376d2d641f25cb18346 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Sat, 25 Jun 2022 11:14:10 +0800 Subject: [PATCH] os: add alloca func --- include/os/os.h | 1 + include/os/osMath.h | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/os/os.h b/include/os/os.h index 254c16efbe..3e72a618a0 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -52,6 +52,7 @@ extern "C" { #endif #else +#include #include #ifndef TD_USE_WINSOCK #include diff --git a/include/os/osMath.h b/include/os/osMath.h index f17ca56c9e..e13c32422e 100644 --- a/include/os/osMath.h +++ b/include/os/osMath.h @@ -25,11 +25,10 @@ extern "C" { #define TSWAP(a, b) \ do { \ - char *__tmp = taosMemoryMalloc(sizeof(a)); \ + char *__tmp = alloca(sizeof(a)); \ memcpy(__tmp, &(a), sizeof(a)); \ memcpy(&(a), &(b), sizeof(a)); \ memcpy(&(b), __tmp, sizeof(a)); \ - taosMemoryFree(__tmp); \ } while (0) #ifdef WINDOWS