os: add alloca func
This commit is contained in:
parent
c70a930dea
commit
925276e449
|
@ -52,6 +52,7 @@ extern "C" {
|
|||
#endif
|
||||
#else
|
||||
|
||||
#include <malloc.h>
|
||||
#include <time.h>
|
||||
#ifndef TD_USE_WINSOCK
|
||||
#include <winsock2.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
|
||||
|
|
Loading…
Reference in New Issue