From 29030b54c98b0aee65fbc10ebf7ba36bed98c02c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 10 Aug 2013 18:02:44 +0200 Subject: util/Error: new error passing library Replaces GLib's GError. --- src/playlist/SoundCloudPlaylistPlugin.cxx | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/playlist/SoundCloudPlaylistPlugin.cxx') diff --git a/src/playlist/SoundCloudPlaylistPlugin.cxx b/src/playlist/SoundCloudPlaylistPlugin.cxx index b60635049..b6be4fd30 100644 --- a/src/playlist/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/SoundCloudPlaylistPlugin.cxx @@ -24,6 +24,7 @@ #include "InputLegacy.hxx" #include "Song.hxx" #include "Tag.hxx" +#include "util/Error.hxx" #include #include @@ -244,18 +245,15 @@ static int soundcloud_parse_json(const char *url, yajl_handle hand, Mutex &mutex, Cond &cond) { - struct input_stream *input_stream; - GError *error = NULL; char buffer[4096]; unsigned char *ubuffer = (unsigned char *)buffer; - size_t nbytes; - input_stream = input_stream_open(url, mutex, cond, &error); + Error error; + input_stream *input_stream = input_stream_open(url, mutex, cond, + error); if (input_stream == NULL) { - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); - } + if (error.IsDefined()) + g_warning("%s", error.GetMessage()); return -1; } @@ -266,12 +264,13 @@ soundcloud_parse_json(const char *url, yajl_handle hand, int done = 0; while (!done) { - nbytes = input_stream_read(input_stream, buffer, sizeof(buffer), &error); + const size_t nbytes = + input_stream_read(input_stream, buffer, sizeof(buffer), + error); if (nbytes == 0) { - if (error != NULL) { - g_warning("%s", error->message); - g_error_free(error); - } + if (error.IsDefined()) + g_warning("%s", error.GetMessage()); + if (input_stream_eof(input_stream)) { done = true; } else { -- cgit v1.2.3