[gdk-pixbuf] Unify sniff buffer size
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] Unify sniff buffer size
- Date: Tue, 17 Dec 2013 13:58:02 +0000 (UTC)
commit 0352f8589831a7f76f3c66db643c4bf920422110
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 17 08:51:09 2013 -0500
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.
gdk-pixbuf/gdk-pixbuf-io.c | 2 --
gdk-pixbuf/gdk-pixbuf-loader.c | 10 ++++------
gdk-pixbuf/gdk-pixbuf-private.h | 1 +
3 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index dac21b8..a3442aa 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 9acb10d..96920e0 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 e13426d..444ff37 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]