summaryrefslogtreecommitdiffstats
path: root/subsurface-core/strndup.h
diff options
context:
space:
mode:
Diffstat (limited to 'subsurface-core/strndup.h')
-rw-r--r--subsurface-core/strndup.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/subsurface-core/strndup.h b/subsurface-core/strndup.h
new file mode 100644
index 000000000..84e18b60f
--- /dev/null
+++ b/subsurface-core/strndup.h
@@ -0,0 +1,21 @@
+#ifndef STRNDUP_H
+#define STRNDUP_H
+#if __WIN32__
+static char *strndup (const char *s, size_t n)
+{
+ char *cpy;
+ size_t len = strlen(s);
+ if (n < len)
+ len = n;
+ if ((cpy = malloc(len + 1)) !=
+ NULL) {
+ cpy[len] =
+ '\0';
+ memcpy(cpy,
+ s,
+ len);
+ }
+ return cpy;
+}
+#endif
+#endif /* STRNDUP_H */