mirror of https://github.com/OpenTTD/OpenTTD
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>pull/7759/head
parent
66c32533ec
commit
51f8c8a568
|
@ -107,6 +107,23 @@ static char *strecat(char *dst, const char *src, const char *last)
|
||||||
return strecpy(dst, src, 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.
|
* Version of the standard free that accepts const pointers.
|
||||||
* @param ptr The data to free.
|
* @param ptr The data to free.
|
||||||
|
|
Loading…
Reference in New Issue