diff options
author | Max Kellermann <max@duempel.org> | 2015-09-30 22:03:01 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-09-30 22:21:46 +0200 |
commit | 356c829b767863512da1792c048f6ddbeb8457a3 (patch) | |
tree | 7b71365eb164719ddf12d081766520ee4938bc28 /src/tag/ApeReplayGain.cxx | |
parent | ffbb5c48ed3edaeb72b26b61637eb3bd1cea9e32 (diff) | |
download | mpd-356c829b767863512da1792c048f6ddbeb8457a3.tar.gz mpd-356c829b767863512da1792c048f6ddbeb8457a3.tar.xz mpd-356c829b767863512da1792c048f6ddbeb8457a3.zip |
util/StringView: new utility class
Diffstat (limited to 'src/tag/ApeReplayGain.cxx')
-rw-r--r-- | src/tag/ApeReplayGain.cxx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/tag/ApeReplayGain.cxx b/src/tag/ApeReplayGain.cxx index 139d44d1f..883885369 100644 --- a/src/tag/ApeReplayGain.cxx +++ b/src/tag/ApeReplayGain.cxx @@ -21,15 +21,16 @@ #include "ApeReplayGain.hxx" #include "ApeLoader.hxx" #include "ReplayGain.hxx" -#include "util/ASCII.hxx" #include "fs/Path.hxx" +#include "util/ASCII.hxx" +#include "util/StringView.hxx" #include <string.h> #include <stdlib.h> static bool replay_gain_ape_callback(unsigned long flags, const char *key, - const char *_value, size_t value_length, + StringView _value, ReplayGainInfo &info) { /* we only care about utf-8 text tags */ @@ -37,11 +38,11 @@ replay_gain_ape_callback(unsigned long flags, const char *key, return false; char value[16]; - if (value_length >= sizeof(value)) + if (_value.size >= sizeof(value)) return false; - memcpy(value, _value, value_length); - value[value_length] = 0; + memcpy(value, _value.data, _value.size); + value[_value.size] = 0; return ParseReplayGainTag(info, key, value); } @@ -53,10 +54,9 @@ replay_gain_ape_read(Path path_fs, ReplayGainInfo &info) auto callback = [&info, &found] (unsigned long flags, const char *key, - const char *value, - size_t value_length) { + StringView value) { found |= replay_gain_ape_callback(flags, key, - value, value_length, + value, info); return true; }; |