mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 12:42:02 +00:00
freetdm: windows fixes
This commit is contained in:
@@ -48,17 +48,67 @@ extern "C" {
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/*! \brief sleep x amount of milliseconds */
|
||||
#ifdef __WINDOWS__
|
||||
#define ftdm_sleep(x) Sleep(x)
|
||||
#else
|
||||
#define ftdm_sleep(x) usleep(x * 1000)
|
||||
#endif
|
||||
|
||||
/*! \brief strncpy replacement */
|
||||
#define ftdm_copy_string(x,y,z) strncpy(x, y, z - 1)
|
||||
|
||||
/*! \brief strncpy into a fixed-length buffer */
|
||||
#define ftdm_set_string(x,y) strncpy(x, y, sizeof(x)-1)
|
||||
|
||||
/*! \brief check for null or zero length string buffer */
|
||||
#define ftdm_strlen_zero(s) (!s || *s == '\0')
|
||||
|
||||
/*! \brief check for zero length string buffer */
|
||||
#define ftdm_strlen_zero_buf(s) (*s == '\0')
|
||||
|
||||
/*! \brief The memory handler.
|
||||
Do not use directly this variable, use the memory macros and ftdm_global_set_memory_handler to override */
|
||||
FT_DECLARE_DATA extern ftdm_memory_handler_t g_ftdm_mem_handler;
|
||||
|
||||
/*!
|
||||
\brief Allocate uninitialized memory
|
||||
\param chunksize the chunk size
|
||||
*/
|
||||
#define ftdm_malloc(chunksize) g_ftdm_mem_handler.malloc(g_ftdm_mem_handler.pool, chunksize)
|
||||
|
||||
/*!
|
||||
\brief Reallocates memory
|
||||
\param buff the buffer
|
||||
\param chunksize the chunk size
|
||||
*/
|
||||
#define ftdm_realloc(buff, chunksize) g_ftdm_mem_handler.realloc(g_ftdm_mem_handler.pool, buff, chunksize)
|
||||
|
||||
/*!
|
||||
\brief Allocate initialized memory
|
||||
\param chunksize the chunk size
|
||||
*/
|
||||
#define ftdm_calloc(elements, chunksize) g_ftdm_mem_handler.calloc(g_ftdm_mem_handler.pool, elements, chunksize)
|
||||
|
||||
/*!
|
||||
\brief Free chunk of memory
|
||||
\param chunksize the chunk size
|
||||
*/
|
||||
#define ftdm_free(chunk) g_ftdm_mem_handler.free(g_ftdm_mem_handler.pool, chunk)
|
||||
|
||||
/*!
|
||||
\brief Free a pointer and set it to NULL unless it already is NULL
|
||||
\param it the pointer
|
||||
*/
|
||||
#define ftdm_safe_free(it) if (it) { ftdm_free(it); it = NULL; }
|
||||
|
||||
/*! \brief Duplicate string */
|
||||
FT_DECLARE(char *) ftdm_strdup(const char *str);
|
||||
|
||||
/*! \brief Duplicate string with limit */
|
||||
FT_DECLARE(char *) ftdm_strndup(const char *str, ftdm_size_t inlen);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern C */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user