diff options
author | Cameron Cawley | 2018-08-18 13:34:28 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-18 16:30:05 +0200 |
commit | 7a437e909ce81894d4ad9f1e22b55e609becb9bb (patch) | |
tree | 469fa427f5a571e32c249e803dcacde795124a24 /common | |
parent | d43732ac47bacab53578c6217cb4dbd42da6b9c6 (diff) | |
download | scummvm-rg350-7a437e909ce81894d4ad9f1e22b55e609becb9bb.tar.gz scummvm-rg350-7a437e909ce81894d4ad9f1e22b55e609becb9bb.tar.bz2 scummvm-rg350-7a437e909ce81894d4ad9f1e22b55e609becb9bb.zip |
COMMON: Move new_strdup to common/str.cpp
Diffstat (limited to 'common')
-rw-r--r-- | common/str.cpp | 10 | ||||
-rw-r--r-- | common/str.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp index 468d1a6f53..f60d7d5e93 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -1058,3 +1058,13 @@ int scumm_strnicmp(const char *s1, const char *s2, uint n) { } while (l1 == l2 && l1 != 0); return l1 - l2; } + +// Portable implementation of strdup. +char *scumm_strdup(const char *in) { + const size_t len = strlen(in) + 1; + char *out = new char[len]; + if (out) { + strcpy(out, in); + } + return out; +} diff --git a/common/str.h b/common/str.h index 7a1706b7e1..5ed14b6942 100644 --- a/common/str.h +++ b/common/str.h @@ -482,5 +482,6 @@ size_t strnlen(const char *src, size_t maxSize); extern int scumm_stricmp(const char *s1, const char *s2); extern int scumm_strnicmp(const char *s1, const char *s2, uint n); +extern char *scumm_strdup(const char *in); #endif |