aboutsummaryrefslogtreecommitdiffstats
path: root/src/IcyMetaDataServer.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-19 16:58:45 +0200
committerMax Kellermann <max@duempel.org>2013-10-19 17:24:21 +0200
commit5dc4cbdf82191bc29afc414ac10204bd17275d69 (patch)
tree76ad2e5c60de0e3f504a84cd1d6cff912153adbf /src/IcyMetaDataServer.cxx
parent1434e5a22e82b4176c24c536a91eefa183b78516 (diff)
downloadmpd-5dc4cbdf82191bc29afc414ac10204bd17275d69.tar.gz
mpd-5dc4cbdf82191bc29afc414ac10204bd17275d69.tar.xz
mpd-5dc4cbdf82191bc29afc414ac10204bd17275d69.zip
util/FormatString: new library to replace g_strdup_printf()
Diffstat (limited to '')
-rw-r--r--src/IcyMetaDataServer.cxx55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/IcyMetaDataServer.cxx b/src/IcyMetaDataServer.cxx
index 051a240ba..255f5b53f 100644
--- a/src/IcyMetaDataServer.cxx
+++ b/src/IcyMetaDataServer.cxx
@@ -21,6 +21,7 @@
#include "IcyMetaDataServer.hxx"
#include "Page.hxx"
#include "tag/Tag.hxx"
+#include "util/FormatString.hxx"
#include <glib.h>
@@ -32,26 +33,26 @@ icy_server_metadata_header(const char *name,
const char *genre, const char *url,
const char *content_type, int metaint)
{
- return g_strdup_printf("ICY 200 OK\r\n"
- "icy-notice1:<BR>This stream requires an audio player!<BR>\r\n" /* TODO */
- "icy-notice2:MPD - The music player daemon<BR>\r\n"
- "icy-name: %s\r\n" /* TODO */
- "icy-genre: %s\r\n" /* TODO */
- "icy-url: %s\r\n" /* TODO */
- "icy-pub:1\r\n"
- "icy-metaint:%d\r\n"
- /* TODO "icy-br:%d\r\n" */
- "Content-Type: %s\r\n"
- "Connection: close\r\n"
- "Pragma: no-cache\r\n"
- "Cache-Control: no-cache, no-store\r\n"
- "\r\n",
- name,
- genre,
- url,
- metaint,
- /* bitrate, */
- content_type);
+ return FormatNew("ICY 200 OK\r\n"
+ "icy-notice1:<BR>This stream requires an audio player!<BR>\r\n" /* TODO */
+ "icy-notice2:MPD - The music player daemon<BR>\r\n"
+ "icy-name: %s\r\n" /* TODO */
+ "icy-genre: %s\r\n" /* TODO */
+ "icy-url: %s\r\n" /* TODO */
+ "icy-pub:1\r\n"
+ "icy-metaint:%d\r\n"
+ /* TODO "icy-br:%d\r\n" */
+ "Content-Type: %s\r\n"
+ "Connection: close\r\n"
+ "Pragma: no-cache\r\n"
+ "Cache-Control: no-cache, no-store\r\n"
+ "\r\n",
+ name,
+ genre,
+ url,
+ metaint,
+ /* bitrate, */
+ content_type);
}
static char *
@@ -61,12 +62,10 @@ icy_server_metadata_string(const char *stream_title, const char* stream_url)
guint meta_length;
// The leading n is a placeholder for the length information
- icy_metadata = g_strdup_printf("nStreamTitle='%s';"
- "StreamUrl='%s';",
- stream_title,
- stream_url);
-
- g_return_val_if_fail(icy_metadata, NULL);
+ icy_metadata = FormatNew("nStreamTitle='%s';"
+ "StreamUrl='%s';",
+ stream_title,
+ stream_url);
meta_length = strlen(icy_metadata);
@@ -77,7 +76,7 @@ icy_server_metadata_string(const char *stream_title, const char* stream_url)
icy_metadata[0] = meta_length;
if (meta_length > 255) {
- g_free(icy_metadata);
+ delete[] icy_metadata;
return NULL;
}
@@ -130,7 +129,7 @@ icy_server_metadata_page(const Tag &tag, const enum tag_type *types)
Page *icy_metadata = Page::Copy(icy_string, (icy_string[0] * 16) + 1);
- g_free(icy_string);
+ delete[] icy_string;
return icy_metadata;
}