aboutsummaryrefslogtreecommitdiffstats
path: root/src/IcyMetaDataParser.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/IcyMetaDataParser.cxx')
-rw-r--r--src/IcyMetaDataParser.cxx18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/IcyMetaDataParser.cxx b/src/IcyMetaDataParser.cxx
index 8861efb2e..5444db8d9 100644
--- a/src/IcyMetaDataParser.cxx
+++ b/src/IcyMetaDataParser.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "IcyMetaDataParser.hxx"
#include "tag/Tag.hxx"
+#include "tag/TagBuilder.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
@@ -37,7 +38,7 @@ IcyMetaDataParser::Reset()
return;
if (data_rest == 0 && meta_size > 0)
- g_free(meta_data);
+ delete[] meta_data;
delete tag;
@@ -66,7 +67,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 +82,7 @@ icy_add_item(Tag &tag, TagType type, const char *value)
}
static void
-icy_parse_tag_item(Tag &tag, const char *item)
+icy_parse_tag_item(TagBuilder &tag, const char *item)
{
gchar **p = g_strsplit(item, "=", 0);
@@ -99,15 +100,16 @@ icy_parse_tag_item(Tag &tag, const char *item)
static Tag *
icy_parse_tag(const char *p)
{
- Tag *tag = new Tag();
+ TagBuilder tag;
+
gchar **items = g_strsplit(p, ";", 0);
for (unsigned i = 0; items[i] != nullptr; ++i)
- icy_parse_tag_item(*tag, items[i]);
+ icy_parse_tag_item(tag, items[i]);
g_strfreev(items);
- return tag;
+ return tag.Commit();
}
size_t
@@ -136,7 +138,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);
@@ -161,7 +163,7 @@ IcyMetaDataParser::Meta(const void *data, size_t length)
delete tag;
tag = icy_parse_tag(meta_data);
- g_free(meta_data);
+ delete[] meta_data;
/* change back to normal data mode */