diff --git a/src/libstrongswan/utils/windows.h b/src/libstrongswan/utils/windows.h index 8c009cabb..90c92fd60 100644 --- a/src/libstrongswan/utils/windows.h +++ b/src/libstrongswan/utils/windows.h @@ -67,6 +67,21 @@ static inline void srandom(unsigned int seed) srand(seed); } +/** + * strdup(3), the Windows variant can't free(strdup("")) and others + */ +#define strdup strdup_windows +static inline char* strdup_windows(const char *src) +{ + size_t len; + char *dst; + + len = strlen(src) + 1; + dst = malloc(len); + memcpy(dst, src, len); + return dst; +} + /** * Provided via ws2_32 */