[librsvg/librsvg-2.40] Use a different reading state when reading compressed data
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.40] Use a different reading state when reading compressed data
- Date: Wed, 4 Oct 2017 01:06:10 +0000 (UTC)
commit a8b10c704327c01f9e9ed50d7ee9672021ae9e70
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Oct 3 15:10:27 2017 -0500
Use a different reading state when reading compressed data
This is to avoid having special cases everywhere if
priv->compressed_input_stream is present.
rsvg-base.c | 19 +++++++++----------
rsvg-private.h | 1 +
2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 16524a2..6b7a2dd 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1767,6 +1767,7 @@ rsvg_handle_write (RsvgHandle * handle, const guchar * buf, gsize count, GError
rsvg_return_val_if_fail (priv->state == RSVG_HANDLE_STATE_START
|| priv->state == RSVG_HANDLE_STATE_EXPECTING_GZ_1
+ || priv->state == RSVG_HANDLE_STATE_READING_COMPRESSED
|| priv->state == RSVG_HANDLE_STATE_READING,
FALSE,
error);
@@ -1787,7 +1788,7 @@ rsvg_handle_write (RsvgHandle * handle, const guchar * buf, gsize count, GError
case RSVG_HANDLE_STATE_EXPECTING_GZ_1:
if (buf[0] == GZ_MAGIC_1) {
- priv->state = RSVG_HANDLE_STATE_READING;
+ priv->state = RSVG_HANDLE_STATE_READING_COMPRESSED;
create_compressed_input_stream (handle);
buf++;
count--;
@@ -1798,15 +1799,13 @@ rsvg_handle_write (RsvgHandle * handle, const guchar * buf, gsize count, GError
break;
+ case RSVG_HANDLE_STATE_READING_COMPRESSED:
+ g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (priv->compressed_input_stream),
+ g_memdup (buf, count), count, (GDestroyNotify) g_free);
+ return TRUE;
+
case RSVG_HANDLE_STATE_READING:
- if (priv->compressed_input_stream) {
- g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (priv->compressed_input_stream),
- g_memdup (buf, count), count, (GDestroyNotify) g_free);
- return TRUE;
- } else {
- return rsvg_handle_write_impl (handle, buf, count, error);
- }
- break;
+ return rsvg_handle_write_impl (handle, buf, count, error);
default:
g_assert_not_reached ();
@@ -1842,7 +1841,7 @@ rsvg_handle_close (RsvgHandle * handle, GError ** error)
return TRUE;
}
- if (priv->compressed_input_stream) {
+ if (priv->state == RSVG_HANDLE_STATE_READING_COMPRESSED) {
gboolean ret;
ret = rsvg_handle_read_stream_sync (handle, priv->compressed_input_stream, NULL, error);
diff --git a/rsvg-private.h b/rsvg-private.h
index 8dfdfbf..68ab06e 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -132,6 +132,7 @@ typedef enum {
typedef enum {
RSVG_HANDLE_STATE_START,
RSVG_HANDLE_STATE_EXPECTING_GZ_1,
+ RSVG_HANDLE_STATE_READING_COMPRESSED,
RSVG_HANDLE_STATE_READING,
RSVG_HANDLE_STATE_CLOSED_OK,
RSVG_HANDLE_STATE_CLOSED_ERROR
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]