Add a simple strndup() implementation for win32.
This commit is contained in:
parent
ee5bd670d4
commit
38d5e58e22
@ -37,7 +37,15 @@
|
|||||||
|
|
||||||
/* strndup() is a GNU extension. Other systems must fix it with elif's. */
|
/* strndup() is a GNU extension. Other systems must fix it with elif's. */
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
extern char *strndup(__const char *__string, size_t __n);
|
extern char *strndup(__const char *__string, size_t __n);
|
||||||
|
#elif defined(WIN32)
|
||||||
|
static char *strndup(const char *__string, size_t __n)
|
||||||
|
{
|
||||||
|
size_t strsize = strnlen(__string,__n);
|
||||||
|
char *newstr = (char *) malloc(strsize + 1);
|
||||||
|
strncpy(newstr,__string,__n);
|
||||||
|
return(newstr);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user