summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-12-17 08:51:09 -0500
committerMatthias Clasen <mclasen@redhat.com>2013-12-17 08:54:06 -0500
commit0352f8589831a7f76f3c66db643c4bf920422110 (patch)
tree8dc4420ad375aea8de8282f0e68db6b71833afa9
parente19cae6b33322438d849653ae4a973b4c56ca468 (diff)
downloadgdk-pixbuf-0352f8589831a7f76f3c66db643c4bf920422110.tar.gz
Unify sniff buffer size
GdkPixbufLoader was using 1k as a buffer size for sniffing file types, and the gdk_pixbuf_new_from_file() family of functions was using 4k, for no good reason. Unify this so we use the same buffer size everywhere.
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.c2
-rw-r--r--gdk-pixbuf/gdk-pixbuf-loader.c10
-rw-r--r--gdk-pixbuf/gdk-pixbuf-private.h1
3 files changed, 5 insertions, 8 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index dac21b8fa..a3442aa20 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -47,8 +47,6 @@
#undef STRICT
#endif
-#define SNIFF_BUFFER_SIZE 4096
-
/**
* SECTION:file-loading
* @Short_description: Loading a pixbuf from a file.
diff --git a/gdk-pixbuf/gdk-pixbuf-loader.c b/gdk-pixbuf/gdk-pixbuf-loader.c
index 9acb10deb..96920e071 100644
--- a/gdk-pixbuf/gdk-pixbuf-loader.c
+++ b/gdk-pixbuf/gdk-pixbuf-loader.c
@@ -111,13 +111,11 @@ static guint pixbuf_loader_signals[LAST_SIGNAL] = { 0 };
/* Internal data */
-#define LOADER_HEADER_SIZE 1024
-
typedef struct
{
GdkPixbufAnimation *animation;
gboolean closed;
- guchar header_buf[LOADER_HEADER_SIZE];
+ guchar header_buf[SNIFF_BUFFER_SIZE];
gint header_buf_offset;
GdkPixbufModule *image_module;
gpointer context;
@@ -466,12 +464,12 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader,
gint n_bytes;
GdkPixbufLoaderPrivate *priv = loader->priv;
- n_bytes = MIN(LOADER_HEADER_SIZE - priv->header_buf_offset, count);
+ n_bytes = MIN(SNIFF_BUFFER_SIZE - priv->header_buf_offset, count);
memcpy (priv->header_buf + priv->header_buf_offset, buf, n_bytes);
priv->header_buf_offset += n_bytes;
- if (priv->header_buf_offset >= LOADER_HEADER_SIZE)
+ if (priv->header_buf_offset >= SNIFF_BUFFER_SIZE)
{
if (gdk_pixbuf_loader_load_module (loader, NULL, error) == 0)
return 0;
@@ -797,7 +795,7 @@ gdk_pixbuf_loader_close (GdkPixbufLoader *loader,
if (priv->closed)
return TRUE;
- /* We have less the LOADER_HEADER_SIZE bytes in the image.
+ /* We have less than SNIFF_BUFFER_SIZE bytes in the image.
* Flush it, and keep going.
*/
if (priv->image_module == NULL)
diff --git a/gdk-pixbuf/gdk-pixbuf-private.h b/gdk-pixbuf/gdk-pixbuf-private.h
index e13426d91..444ff3730 100644
--- a/gdk-pixbuf/gdk-pixbuf-private.h
+++ b/gdk-pixbuf/gdk-pixbuf-private.h
@@ -36,6 +36,7 @@
#include "gdk-pixbuf-i18n.h"
#define LOAD_BUFFER_SIZE 65536
+#define SNIFF_BUFFER_SIZE 4096