summaryrefslogtreecommitdiff
path: root/src/depend
diff options
context:
space:
mode:
authorJoe Stringer <joe@wand.net.nz>2019-10-04 22:50:29 -0700
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-10-07 21:36:00 +0200
commit51f8c8a568158dcf164c0cbe389123fa9b6b190c (patch)
treeaa4c1d52985463829f1c6786f35df9d6d590fdb1 /src/depend
parent66c32533ec2adfea49579e0a64e3d32de2fa438c (diff)
downloadopenttd-51f8c8a568158dcf164c0cbe389123fa9b6b190c.tar.xz
Fix: [Cygwin] Fix missing declaration of strdup()
src/depend/depend.cpp: In constructor 'File::File(const char*)': src/depend/depend.cpp:170:19: error: 'strdup' was not declared in this scope this->dirname = strdup(filename); ^~~~~~ Signed-off-by: Joe Stringer <joe@wand.net.nz>
Diffstat (limited to 'src/depend')
-rw-r--r--src/depend/depend.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/depend/depend.cpp b/src/depend/depend.cpp
index 9321e573b..a5d35c635 100644
--- a/src/depend/depend.cpp
+++ b/src/depend/depend.cpp
@@ -107,6 +107,23 @@ static char *strecat(char *dst, const char *src, const char *last)
return strecpy(dst, src, last);
}
+#if defined(__CYGWIN__)
+/**
+ * Version of strdup copied from glibc.
+ * Duplicate S, returning an identical malloc'd string.
+ * @param s The string to duplicate.
+ */
+char *
+strdup (const char *s)
+{
+ size_t len = strlen(s) + 1;
+ void *n = malloc(len);
+
+ if (n == NULL) return NULL;
+ return (char *) memcpy(n, s, len);
+}
+#endif
+
/**
* Version of the standard free that accepts const pointers.
* @param ptr The data to free.