[librsvg] Create the compressed_input_stream in a separate function
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Create the compressed_input_stream in a separate function
- Date: Wed, 4 Oct 2017 00:52:59 +0000 (UTC)
commit 2f75588d304fb579d7b2e8416f863c6a2b954ab4
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Oct 3 15:06:08 2017 -0500
Create the compressed_input_stream in a separate function
rsvg-base.c | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index bc1cd1e..73a821b 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1862,6 +1862,24 @@ rsvg_handle_set_size_callback (RsvgHandle * handle,
#define GZ_MAGIC_0 ((guchar) 0x1f)
#define GZ_MAGIC_1 ((guchar) 0x8b)
+/* Creates handle->priv->compressed_input_stream and adds the gzip header data
+ * to it. We implicitly consume the header data from the caller in
+ * rsvg_handle_write(); that's why we add it back here.
+ */
+static void
+create_compressed_input_stream (RsvgHandle *handle)
+{
+ RsvgHandlePrivate *priv = handle->priv;
+
+ static const guchar gz_magic[2] = { GZ_MAGIC_0, GZ_MAGIC_1 };
+
+ g_assert (priv->compressed_input_stream == NULL);
+
+ priv->compressed_input_stream = g_memory_input_stream_new ();
+ g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (priv->compressed_input_stream),
+ gz_magic, 2, NULL);
+}
+
/**
* rsvg_handle_write:
* @handle: an #RsvgHandle
@@ -1907,13 +1925,8 @@ rsvg_handle_write (RsvgHandle * handle, const guchar * buf, gsize count, GError
case RSVG_HANDLE_STATE_EXPECTING_GZ_1:
if (buf[0] == GZ_MAGIC_1) {
- static const guchar gz_magic[2] = { GZ_MAGIC_0, GZ_MAGIC_1 };
-
- priv->compressed_input_stream = g_memory_input_stream_new ();
- g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (priv->compressed_input_stream),
- gz_magic, 2, NULL);
-
priv->state = RSVG_HANDLE_STATE_READING;
+ create_compressed_input_stream (handle);
buf++;
count--;
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]