diff options
author | Mike Ruprecht <cmaiku@gmail.com> | 2016-08-29 23:43:47 -0500 |
---|---|---|
committer | Mike Ruprecht <cmaiku@gmail.com> | 2016-08-29 23:43:47 -0500 |
commit | ce7ccaa9ef2c3e72ddc082fe16ab3cca2bd40218 (patch) | |
tree | 2c0f67d8bdaa8a3f3b7c8f1f6475edf6890ea494 /libpurple/queuedoutputstream.c | |
parent | ce39d15c0fb535271488d14333a1a13813b54ce7 (diff) | |
download | pidgin-ce7ccaa9ef2c3e72ddc082fe16ab3cca2bd40218.tar.gz |
queuedoutputstream: Remove usage of g_async_queue_push_front()
g_async_queue_push_front() is from GLib 2.46+. As of this commit,
we depend on GLib 2.34, though it should be 2.36, but that's for
another commit. This patch removes usage of that function so we
don't require nearly as high of a GLib version.
Diffstat (limited to 'libpurple/queuedoutputstream.c')
-rw-r--r-- | libpurple/queuedoutputstream.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libpurple/queuedoutputstream.c b/libpurple/queuedoutputstream.c index 83bc98a3f1..06e559e366 100644 --- a/libpurple/queuedoutputstream.c +++ b/libpurple/queuedoutputstream.c @@ -26,6 +26,7 @@ struct _PurpleQueuedOutputStreamPrivate { GAsyncQueue *queue; + GBytes *next; }; GObjectClass *parent_class = NULL; @@ -99,26 +100,32 @@ purple_queued_output_stream_dispose(GObject *object) G_OBJECT_CLASS(parent_class)->dispose(object); g_clear_pointer(&stream->priv->queue, g_async_queue_unref); + g_clear_pointer(&stream->priv->next, g_bytes_unref); } static gboolean purple_queued_output_stream_flush(GOutputStream *stream, GCancellable *cancellable, GError **error) { + PurpleQueuedOutputStreamPrivate *priv; GOutputStream *base_stream; - GAsyncQueue *queue; GBytes *bytes; const void *buffer; gsize count; gsize bytes_written = 0; gboolean ret = TRUE; + priv = PURPLE_QUEUED_OUTPUT_STREAM(stream)->priv; base_stream = g_filter_output_stream_get_base_stream( G_FILTER_OUTPUT_STREAM(stream)); - queue = PURPLE_QUEUED_OUTPUT_STREAM(stream)->priv->queue; do { - bytes = g_async_queue_try_pop(queue); + if (priv->next != NULL) { + bytes = priv->next; + priv->next = NULL; + } else { + bytes = g_async_queue_try_pop(priv->queue); + } if (bytes == NULL) { break; @@ -140,7 +147,7 @@ purple_queued_output_stream_flush(GOutputStream *stream, queue_bytes = g_bytes_ref(bytes); } - g_async_queue_push_front(queue, queue_bytes); + priv->next = queue_bytes; } g_bytes_unref(bytes); |