mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-28 00:49:11 +00:00
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>
This commit is contained in:
committed by
Niels Martin Hansen
parent
66c32533ec
commit
51f8c8a568
@@ -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.
|
||||
|
Reference in New Issue
Block a user