From 51f8c8a568158dcf164c0cbe389123fa9b6b190c Mon Sep 17 00:00:00 2001 From: Joe Stringer Date: Fri, 4 Oct 2019 22:50:29 -0700 Subject: 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 --- src/depend/depend.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/depend') 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. -- cgit v1.2.3-70-g09d2