aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-06 09:32:08 +0200
committerMax Kellermann <max@duempel.org>2013-08-06 09:32:08 +0200
commit132971f8ebfc5092cab9899f35dfa7d31402cebc (patch)
tree7a3e3b277d6466431cd6e2b34a125903395ba058 /src
parent3f04a4d635bf217126298df5e1c2d95bce94f764 (diff)
downloadmpd-132971f8ebfc5092cab9899f35dfa7d31402cebc.tar.gz
mpd-132971f8ebfc5092cab9899f35dfa7d31402cebc.tar.xz
mpd-132971f8ebfc5092cab9899f35dfa7d31402cebc.zip
playlist/pls: use std::string instead of GString
Diffstat (limited to '')
-rw-r--r--src/playlist/PlsPlaylistPlugin.cxx17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/playlist/PlsPlaylistPlugin.cxx b/src/playlist/PlsPlaylistPlugin.cxx
index fdb7db77a..4a6024ed6 100644
--- a/src/playlist/PlsPlaylistPlugin.cxx
+++ b/src/playlist/PlsPlaylistPlugin.cxx
@@ -26,6 +26,8 @@
#include <glib.h>
+#include <string>
+
static void
pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
{
@@ -106,14 +108,14 @@ pls_open_stream(struct input_stream *is)
char buffer[1024];
bool success;
GKeyFile *keyfile;
- GString *kf_data = g_string_new("");
+
+ std::string kf_data;
do {
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
&error);
if (nbytes == 0) {
if (error != NULL) {
- g_string_free(kf_data, TRUE);
g_warning("%s", error->message);
g_error_free(error);
return NULL;
@@ -122,23 +124,20 @@ pls_open_stream(struct input_stream *is)
break;
}
- kf_data = g_string_append_len(kf_data, buffer,nbytes);
+ kf_data.append(buffer, nbytes);
/* Limit to 64k */
- } while(kf_data->len < 65536);
+ } while (kf_data.length() < 65536);
- if (kf_data->len == 0) {
+ if (kf_data.empty()) {
g_warning("KeyFile parser failed: No Data");
- g_string_free(kf_data, TRUE);
return NULL;
}
keyfile = g_key_file_new();
success = g_key_file_load_from_data(keyfile,
- kf_data->str, kf_data->len,
+ kf_data.data(), kf_data.length(),
G_KEY_FILE_NONE, &error);
- g_string_free(kf_data, TRUE);
-
if (!success) {
g_warning("KeyFile parser failed: %s", error->message);
g_error_free(error);