? gconf-2.m4
? gconf-zip
? mkinstalldirs
? stamp-h1
Index: backends/xml-dir.c
===================================================================
RCS file: /cvs/gnome/gconf/backends/xml-dir.c,v
retrieving revision 1.35
diff -u -r1.35 xml-dir.c
--- backends/xml-dir.c	18 Mar 2005 15:08:10 -0000	1.35
+++ backends/xml-dir.c	9 Jun 2005 09:26:44 -0000
@@ -17,6 +17,11 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
 #include "xml-dir.h"
 #include "xml-entry.h"
 
@@ -59,7 +64,15 @@
 }
 #endif
 
-static xmlDocPtr my_xml_parse_file (const char *filename,
+typedef struct
+{
+        xmlDocPtr *doc;
+        guchar *text;
+        int fd;
+        struct stat statbuf;
+} parsed_file_info_t;
+
+static parsed_file_info_t* my_xml_parse_file (const char *filename,
                                     GError    **err);
 
 static gboolean dir_rescan_subdirs (Dir* d, GError** err);
@@ -78,6 +91,8 @@
   GSList *subdir_names;
   guint dirty : 1;
   guint need_rescan_subdirs : 1;
+
+  parsed_file_info_t *info;
 };
 
 static void
@@ -242,6 +257,11 @@
 
   if (d->doc != NULL)
     xmlFreeDoc (d->doc);
+ 
+
+  munmap (d->info->text, d->info->statbuf.st_size);
+  close (d->info->fd); 
+  g_free (d->info);
   
   g_free (d);
 }
@@ -1013,8 +1033,10 @@
 
       error_was_fatal = FALSE;
       tmp_err = NULL;
-      d->doc = my_xml_parse_file (d->xml_filename, &tmp_err);
-
+      
+      d->info = my_xml_parse_file (d->xml_filename, &tmp_err);
+      d->doc = d->info->doc;
+      
       if (tmp_err != NULL)
         {
           gconf_log (GCL_WARNING,
@@ -1359,29 +1381,27 @@
   return mode;
 }
 
-static xmlDocPtr
+static parsed_file_info_t*
 my_xml_parse_file (const char *filename,
                    GError    **err)
 {
-  char *text;
-  gsize length;
-  xmlDocPtr doc;
+  parsed_file_info_t *res = g_new0(parsed_file_info_t,1);
   
-  text = NULL;
-  length = 0;
+  res->text = NULL;
+ 
+  if ((res->fd = open (filename, O_RDONLY)) == -1)
+ 	return NULL;
   
-  if (!g_file_get_contents (filename,
-                            &text,
-                            &length,
-                            err))
-    return NULL;
-
-
-  doc = xmlParseMemory (text, length);
-
-  g_free (text);
+  if (fstat (res->fd,&res->statbuf) < 0)
+	  return NULL;
+  
+  if ((res->text = (guchar*)mmap (0, res->statbuf.st_size, PROT_READ, MAP_SHARED, res->fd, 0)) == (guchar*) -1)
+	  return NULL;
+	  
+  
+  res->doc = xmlParseMemory (res->text, res->statbuf.st_size);
 
-  if (doc == NULL)
+  if (res->doc == NULL)
     {
       g_set_error (err,
                    GCONF_ERROR,
@@ -1391,7 +1411,7 @@
       return NULL;
     }
   
-  return doc;
+  return res;
 }
 
 
