? gtk/f
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.6644
diff -u -r1.6644 ChangeLog
--- ChangeLog	5 Jun 2005 10:34:19 -0000	1.6644
+++ ChangeLog	7 Jun 2005 18:25:38 -0000
@@ -1,3 +1,9 @@
+2005-06-07  Philip Van Hoof  <pvanhoof@gnome.org>
+
+	* gdk-pixbuf/gdk-pixbuf-io.c: Replaced an fread with mmap on
+	platforms that support this.
+	* configure.in: Detection for sys/mman.h
+	
 2005-06-05  Tor Lillqvist  <tml@novell.com>
 
 	* gdk/win32/gdkscreen-win32.c
Index: acconfig.h
===================================================================
RCS file: /cvs/gnome/gtk+/acconfig.h,v
retrieving revision 1.29
diff -u -r1.29 acconfig.h
--- acconfig.h	25 Jan 2004 22:19:39 -0000	1.29
+++ acconfig.h	7 Jun 2005 18:25:38 -0000
@@ -37,6 +37,7 @@
 #undef HAVE_WINTAB
 #undef HAVE_XCONVERTCASE
 #undef HAVE_XFT
+#undef HAVE_MMAN_H
 
 #undef HAVE_SIGSETJMP
 
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gtk+/configure.in,v
retrieving revision 1.436
diff -u -r1.436 configure.in
--- configure.in	16 May 2005 18:16:42 -0000	1.436
+++ configure.in	7 Jun 2005 18:25:42 -0000
@@ -506,6 +506,7 @@
 AC_CHECK_HEADERS(pwd.h, AC_DEFINE(HAVE_PWD_H))
 AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
 AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
+AC_CHECK_HEADERS(sys/mman.h, AC_DEFINE(HAVE_MMAN_H))
 
 if test "${with_ie55+set}" = set && test $with_ie55 != no; then
   AC_MSG_CHECKING([for dimm.h])
Index: gdk-pixbuf/gdk-pixbuf-io.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-io.c,v
retrieving revision 1.109
diff -u -r1.109 gdk-pixbuf-io.c
--- gdk-pixbuf/gdk-pixbuf-io.c	24 May 2005 17:09:56 -0000	1.109
+++ gdk-pixbuf/gdk-pixbuf-io.c	7 Jun 2005 18:25:46 -0000
@@ -45,6 +45,13 @@
 #undef STRICT
 #endif
 
+#ifdef HAVE_MMAN_H
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#endif
+
 static gint 
 format_check (GdkPixbufModule *module, guchar *buffer, int size)
 {
@@ -821,9 +828,15 @@
 	GdkPixbuf *pixbuf;
 	int size;
 	FILE *f;
+#ifdef HAVE_MMAN_H
+	guchar *buffer;
+	struct stat statbuf;
+#else
 	guchar buffer [128];
+#endif
 	GdkPixbufModule *image_module;
 	gchar *display_name;
+	int fdin;
 
 	g_return_val_if_fail (filename != NULL, NULL);
         g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -841,9 +854,26 @@
                 g_free (display_name);
 		return NULL;
         }
+	fdin = fileno (f);
+
+#ifdef HAVE_MMAN_H
+	if ((fstat (fdin,&statbuf) < 0) || (statbuf.st_size < 128)) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                             _("Image file '%s' to small to be an image"),
+                             display_name);
+                g_free (display_name);
+		fclose (f);
+		return NULL;
+	}
 
+	size = 128;
+	if ((buffer = (guchar*)mmap (0, size, PROT_READ, MAP_SHARED, fdin, 0)) == (guchar*) -1){
+#else
 	size = fread (&buffer, 1, sizeof (buffer), f);
 	if (size == 0) {
+#endif
                 g_set_error (error,
                              GDK_PIXBUF_ERROR,
                              GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
