diff options
author | Max Kellermann <max@duempel.org> | 2014-05-11 15:32:47 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-05-21 18:47:49 +0200 |
commit | a5d0300787137ec3509956f3ed3fdf0e8656eff6 (patch) | |
tree | 88159211e7a37482b9a422765b721cff3acfd73b /src/IcyMetaDataParser.cxx | |
parent | 09b84c51ee1671e770062bf6148ad65afee6073a (diff) | |
download | mpd-a5d0300787137ec3509956f3ed3fdf0e8656eff6.tar.gz mpd-a5d0300787137ec3509956f3ed3fdf0e8656eff6.tar.xz mpd-a5d0300787137ec3509956f3ed3fdf0e8656eff6.zip |
input/curl: move code to IcyInputStream
Diffstat (limited to '')
-rw-r--r-- | src/IcyMetaDataParser.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/IcyMetaDataParser.cxx b/src/IcyMetaDataParser.cxx index 79023dd64..4c13c2c2c 100644 --- a/src/IcyMetaDataParser.cxx +++ b/src/IcyMetaDataParser.cxx @@ -220,3 +220,32 @@ IcyMetaDataParser::Meta(const void *data, size_t length) return length; } + +size_t +IcyMetaDataParser::ParseInPlace(void *data, size_t length) +{ + uint8_t *const dest0 = (uint8_t *)data; + uint8_t *dest = dest0; + const uint8_t *src = dest0; + + while (length > 0) { + size_t chunk = Data(length); + if (chunk > 0) { + memmove(dest, src, chunk); + dest += chunk; + src += chunk; + length -= chunk; + + if (length == 0) + break; + } + + chunk = Meta(src, length); + if (chunk > 0) { + src += chunk; + length -= chunk; + } + } + + return dest - dest0; +} |