[librsvg] rsvg-base.c: Use constants for the gzip header magic



commit 6e7114d4464af636a86961c4cfe5072f66abd408
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Oct 3 14:22:58 2017 -0500

    rsvg-base.c: Use constants for the gzip header magic

 rsvg-base.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 2917f6c..7554dfb 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1859,6 +1859,9 @@ rsvg_handle_set_size_callback (RsvgHandle * handle,
     handle->priv->user_data_destroy = user_data_destroy;
 }
 
+#define GZ_MAGIC_0 ((guchar) 0x1f)
+#define GZ_MAGIC_1 ((guchar) 0x8b)
+
 /**
  * rsvg_handle_write:
  * @handle: an #RsvgHandle
@@ -1892,7 +1895,7 @@ rsvg_handle_write (RsvgHandle * handle, const guchar * buf, gsize count, GError
 
         /* test for GZ marker. todo: store the first 2 bytes in the odd circumstance that someone calls
          * write() in 1 byte increments */
-        if ((count >= 2) && (buf[0] == (guchar) 0x1f) && (buf[1] == (guchar) 0x8b)) {
+        if ((count >= 2) && (buf[0] == GZ_MAGIC_0) && (buf[1] == GZ_MAGIC_1)) {
             priv->data_input_stream = g_memory_input_stream_new ();
         }
     }
@@ -2010,7 +2013,7 @@ rsvg_handle_read_stream_sync (RsvgHandle   *handle,
         return FALSE;
     }
     buf = g_buffered_input_stream_peek_buffer (G_BUFFERED_INPUT_STREAM (stream), NULL);
-    if ((buf[0] == 0x1f) && (buf[1] == 0x8b)) {
+    if ((buf[0] == GZ_MAGIC_0) && (buf[1] == GZ_MAGIC_1)) {
         GConverter *converter;
         GInputStream *conv_stream;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]