[librsvg] 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] Use a different reading state when reading compressed data
- Date: Wed, 4 Oct 2017 00:53:04 +0000 (UTC)
commit 63c245ec654559da25c8fe5fa4522e560b2c9eaf
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 73a821b..c0b0298 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1905,6 +1905,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);
@@ -1925,7 +1926,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--;
@@ -1936,15 +1937,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 ();
@@ -1980,7 +1979,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 4a6b3a4..a39e5e5 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -127,6 +127,7 @@ struct RsvgSaxHandler {
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]