? 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 19:15:58 -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: 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 19:16:03 -0000
@@ -45,6 +45,12 @@
 #undef STRICT
 #endif
 
+#ifdef HAVE_MMAP
+#include <sys/mman.h>
+#endif
+
+#include <glib/gmacros.h>
+
 static gint 
 format_check (GdkPixbufModule *module, guchar *buffer, int size)
 {
@@ -821,10 +827,17 @@
 	GdkPixbuf *pixbuf;
 	int size;
 	FILE *f;
+#ifdef HAVE_MMAP
+	guchar *buffer;
+	struct stat statbuf;
+	int fdin;
+#else
 	guchar buffer [128];
+#endif
 	GdkPixbufModule *image_module;
 	gchar *display_name;
 
+
 	g_return_val_if_fail (filename != NULL, NULL);
         g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 	
@@ -842,8 +855,26 @@
 		return NULL;
         }
 
+#ifdef HAVE_MMAP
+	fdin = fileno (f);
+
+	if (fstat (fdin,&statbuf) < 0) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                             _("Can't fstat image file '%s'"),
+                             display_name);
+                g_free (display_name);
+		fclose (f);
+		return NULL;
+	}
+
+	size = MIN(statbuf.st_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,
@@ -857,6 +888,9 @@
 	image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
         if (image_module == NULL) {
                 g_free (display_name);
+#ifdef HAVE_MMAP
+                munmap (buffer, size);
+#endif
                 fclose (f);
                 return NULL;
         }
@@ -864,12 +898,18 @@
 	if (image_module->module == NULL)
                 if (!_gdk_pixbuf_load_module (image_module, error)) {
 			g_free (display_name);
+#ifdef HAVE_MMAP
+                        munmap (buffer, size);
+#endif
                         fclose (f);
                         return NULL;
                 }
 
 	fseek (f, 0, SEEK_SET);
 	pixbuf = _gdk_pixbuf_generic_image_load (image_module, f, error);
+#ifdef HAVE_MMAP
+	munmap (buffer, size);
+#endif
 	fclose (f);
 
         if (pixbuf == NULL && error != NULL && *error == NULL) {
