aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/windows.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-10-25 16:41:48 +0200
committerMartin Willi <martin@revosec.ch>2014-06-04 15:53:02 +0200
commitf3c809e615f0e8eb476efcc85a3c8cf2cbe3f7c3 (patch)
tree9a0353c7509eec50e5677b9629576cabdf13c388 /src/libstrongswan/utils/windows.c
parent8f3a3656d371d067e71908e78755bb4a3dd2b057 (diff)
downloadstrongswan-f3c809e615f0e8eb476efcc85a3c8cf2cbe3f7c3.tar.bz2
strongswan-f3c809e615f0e8eb476efcc85a3c8cf2cbe3f7c3.tar.xz
windows: Provide a strndup(3) replacement
Diffstat (limited to 'src/libstrongswan/utils/windows.c')
-rw-r--r--src/libstrongswan/utils/windows.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstrongswan/utils/windows.c b/src/libstrongswan/utils/windows.c
index feefcd497..48a70b6c2 100644
--- a/src/libstrongswan/utils/windows.c
+++ b/src/libstrongswan/utils/windows.c
@@ -49,6 +49,21 @@ int usleep(useconds_t usec)
return 0;
}
+/**
+ * See header.
+ */
+char* strndup(const char *s, size_t n)
+{
+ char *dst;
+
+ n = min(strnlen(s, n), n);
+ dst = malloc(n + 1);
+ memcpy(dst, s, n);
+ dst[n] = '\0';
+
+ return dst;
+}
+
/*
* See header.
*/