windows: Provide a strdup variant safe when passing zero-length strings
This commit is contained in:
@@ -67,6 +67,21 @@ static inline void srandom(unsigned int seed)
|
|||||||
srand(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
|
* Provided via ws2_32
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user