os: add alloca func

This commit is contained in:
afwerar 2022-06-25 11:14:10 +08:00
parent c70a930dea
commit 925276e449
2 changed files with 2 additions and 2 deletions

View File

@ -52,6 +52,7 @@ extern "C" {
#endif #endif
#else #else
#include <malloc.h>
#include <time.h> #include <time.h>
#ifndef TD_USE_WINSOCK #ifndef TD_USE_WINSOCK
#include <winsock2.h> #include <winsock2.h>

View File

@ -25,11 +25,10 @@ extern "C" {
#define TSWAP(a, b) \ #define TSWAP(a, b) \
do { \ do { \
char *__tmp = taosMemoryMalloc(sizeof(a)); \ char *__tmp = alloca(sizeof(a)); \
memcpy(__tmp, &(a), sizeof(a)); \ memcpy(__tmp, &(a), sizeof(a)); \
memcpy(&(a), &(b), sizeof(a)); \ memcpy(&(a), &(b), sizeof(a)); \
memcpy(&(b), __tmp, sizeof(a)); \ memcpy(&(b), __tmp, sizeof(a)); \
taosMemoryFree(__tmp); \
} while (0) } while (0)
#ifdef WINDOWS #ifdef WINDOWS