diff options
author | Max Kellermann <max@duempel.org> | 2014-03-01 09:19:32 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-03-01 18:48:20 +0100 |
commit | 1e06c66c776e2dca217059d7d94309b0c5431a3f (patch) | |
tree | 64b3bf4c5051fabf9dff5b9d0c3ed73b3d2bb45b /src/util/StringUtil.cxx | |
parent | c73771e3ce7a5866f5ddc70d1cc03acf6a104127 (diff) | |
download | mpd-1e06c66c776e2dca217059d7d94309b0c5431a3f.tar.gz mpd-1e06c66c776e2dca217059d7d94309b0c5431a3f.tar.xz mpd-1e06c66c776e2dca217059d7d94309b0c5431a3f.zip |
java: new helper library for the Android port
Diffstat (limited to '')
-rw-r--r-- | src/util/StringUtil.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/StringUtil.cxx b/src/util/StringUtil.cxx index 9a1a74f86..50885a34a 100644 --- a/src/util/StringUtil.cxx +++ b/src/util/StringUtil.cxx @@ -21,6 +21,8 @@ #include "CharUtil.hxx" #include "ASCII.hxx" +#include <algorithm> + #include <assert.h> #include <string.h> @@ -65,6 +67,18 @@ StringEndsWith(const char *haystack, const char *needle) needle, needle_length) == 0; } +char * +CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size) +{ + size_t length = strlen(src); + if (length >= size) + length = size - 1; + + char *p = std::copy(src, src + length, dest); + *p = '\0'; + return p; +} + bool string_array_contains(const char *const* haystack, const char *needle) { |