diff options
Diffstat (limited to 'src/IcyMetaDataParser.cxx')
-rw-r--r-- | src/IcyMetaDataParser.cxx | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/IcyMetaDataParser.cxx b/src/IcyMetaDataParser.cxx index bfa2e8558..79023dd64 100644 --- a/src/IcyMetaDataParser.cxx +++ b/src/IcyMetaDataParser.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -20,11 +20,10 @@ #include "config.h" #include "IcyMetaDataParser.hxx" #include "tag/Tag.hxx" +#include "tag/TagBuilder.hxx" #include "util/Domain.hxx" #include "Log.hxx" -#include <glib.h> - #include <assert.h> #include <string.h> @@ -37,7 +36,7 @@ IcyMetaDataParser::Reset() return; if (data_rest == 0 && meta_size > 0) - g_free(meta_data); + delete[] meta_data; delete tag; @@ -66,7 +65,7 @@ IcyMetaDataParser::Data(size_t length) } static void -icy_add_item(Tag &tag, TagType type, const char *value) +icy_add_item(TagBuilder &tag, TagType type, const char *value) { size_t length = strlen(value); @@ -81,7 +80,7 @@ icy_add_item(Tag &tag, TagType type, const char *value) } static void -icy_parse_tag_item(Tag &tag, const char *name, const char *value) +icy_parse_tag_item(TagBuilder &tag, const char *name, const char *value) { if (strcmp(name, "StreamTitle") == 0) icy_add_item(tag, TAG_TITLE, value); @@ -122,7 +121,7 @@ icy_parse_tag(char *p, char *const end) assert(end != nullptr); assert(p <= end); - Tag *tag = new Tag(); + TagBuilder tag; while (p != end) { const char *const name = p; @@ -153,7 +152,7 @@ icy_parse_tag(char *p, char *const end) *quote = 0; p = quote + 1; - icy_parse_tag_item(*tag, name, value); + icy_parse_tag_item(tag, name, value); char *semicolon = std::find(p, end, ';'); if (semicolon == end) @@ -161,7 +160,7 @@ icy_parse_tag(char *p, char *const end) p = semicolon + 1; } - return tag; + return tag.CommitNew(); } size_t @@ -190,7 +189,7 @@ IcyMetaDataParser::Meta(const void *data, size_t length) /* initialize metadata reader, allocate enough memory (+1 for the null terminator) */ meta_position = 0; - meta_data = (char *)g_malloc(meta_size + 1); + meta_data = new char[meta_size + 1]; } assert(meta_position < meta_size); @@ -211,7 +210,7 @@ IcyMetaDataParser::Meta(const void *data, size_t length) delete tag; tag = icy_parse_tag(meta_data, meta_data + meta_size); - g_free(meta_data); + delete[] meta_data; /* change back to normal data mode */ |