Merge pull request #14227 from taosdata/fix/ZhiqiangWang/TD-16357-add-alloca-func

os: add alloca func
This commit is contained in:
Zhiqiang Wang 2022-06-25 11:40:42 +08:00 committed by GitHub
commit 8171e3264c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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