From 38d5e58e22cdbcf094e836e1d27084c20cb6b779 Mon Sep 17 00:00:00 2001 From: Stefan Sommerfeld Date: Sun, 7 Nov 2010 15:57:14 -0200 Subject: [PATCH] Add a simple strndup() implementation for win32. --- upnp/src/api/UpnpString.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/upnp/src/api/UpnpString.c b/upnp/src/api/UpnpString.c index acf9c70..031ad27 100644 --- a/upnp/src/api/UpnpString.c +++ b/upnp/src/api/UpnpString.c @@ -37,7 +37,15 @@ /* strndup() is a GNU extension. Other systems must fix it with elif's. */ #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