windows: Provide a strdup variant safe when passing zero-length strings
This commit is contained in:
parent
d8e56dfe32
commit
a506b922f3
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue