aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-19 17:18:56 +0200
committerMax Kellermann <max@duempel.org>2013-10-19 17:24:21 +0200
commit0a213ddf037434ec9f2cd1759e3eb747d1972445 (patch)
tree45f83fd5d79799701239037624c1527670070c10 /src
parent5dc4cbdf82191bc29afc414ac10204bd17275d69 (diff)
downloadmpd-0a213ddf037434ec9f2cd1759e3eb747d1972445.tar.gz
mpd-0a213ddf037434ec9f2cd1759e3eb747d1972445.tar.xz
mpd-0a213ddf037434ec9f2cd1759e3eb747d1972445.zip
input/curl: use std::string for meta_name
Automatic memory management.
Diffstat (limited to 'src')
-rw-r--r--src/input/CurlInputPlugin.cxx14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx
index b7142a7e6..d5e8a0038 100644
--- a/src/input/CurlInputPlugin.cxx
+++ b/src/input/CurlInputPlugin.cxx
@@ -158,7 +158,7 @@ struct input_curl {
IcyMetaDataParser icy;
/** the stream name from the icy-name response header */
- char *meta_name;
+ std::string meta_name;
/** the tag object ready to be requested via
input_stream::ReadTag() */
@@ -170,7 +170,6 @@ struct input_curl {
:base(input_plugin_curl, url, mutex, cond),
request_headers(nullptr),
paused(false),
- meta_name(nullptr),
tag(nullptr) {}
~input_curl();
@@ -632,8 +631,6 @@ input_curl::~input_curl()
{
delete tag;
- g_free(meta_name);
-
input_curl_easy_free_indirect(this);
}
@@ -736,8 +733,8 @@ copy_icy_tag(struct input_curl *c)
delete c->tag;
- if (c->meta_name != NULL && !tag->HasType(TAG_NAME))
- tag->AddItem(TAG_NAME, c->meta_name);
+ if (!c->meta_name.empty() && !tag->HasType(TAG_NAME))
+ tag->AddItem(TAG_NAME, c->meta_name.c_str());
c->tag = tag;
}
@@ -862,13 +859,12 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream)
} else if (g_ascii_strcasecmp(name, "icy-name") == 0 ||
g_ascii_strcasecmp(name, "ice-name") == 0 ||
g_ascii_strcasecmp(name, "x-audiocast-name") == 0) {
- g_free(c->meta_name);
- c->meta_name = g_strndup(value, end - value);
+ c->meta_name.assign(value, end);
delete c->tag;
c->tag = new Tag();
- c->tag->AddItem(TAG_NAME, c->meta_name);
+ c->tag->AddItem(TAG_NAME, c->meta_name.c_str());
} else if (g_ascii_strcasecmp(name, "icy-metaint") == 0) {
char buffer[64];
size_t icy_metaint;