From 635a67afac8e8af1a848d67dbfc287eb9b67dd70 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 14 Dec 2013 12:58:26 +0100 Subject: util/SplitString: new utility class To replace g_strdup(). --- src/decoder/VorbisComments.cxx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/decoder/VorbisComments.cxx') diff --git a/src/decoder/VorbisComments.cxx b/src/decoder/VorbisComments.cxx index 4a6cded42..2adc498d5 100644 --- a/src/decoder/VorbisComments.cxx +++ b/src/decoder/VorbisComments.cxx @@ -25,8 +25,7 @@ #include "tag/TagBuilder.hxx" #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" - -#include +#include "util/SplitString.hxx" #include #include @@ -102,16 +101,11 @@ vorbis_scan_comment(const char *comment, const struct tag_handler *handler, void *handler_ctx) { if (handler->pair != nullptr) { - char *name = g_strdup(comment); - char *value = strchr(name, '='); - - if (value != nullptr && value > name) { - *value++ = 0; + const SplitString split(comment, '='); + if (split.IsDefined() && !split.IsEmpty()) tag_handler_invoke_pair(handler, handler_ctx, - name, value); - } - - g_free(name); + split.GetFirst(), + split.GetSecond()); } for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i) -- cgit v1.2.3