--- glib2.0-2.20.0/glib/gutils.c	2009-03-13 05:09:59.000000000 +0100
+++ glib2.0-2.20.0.new/glib/gutils.c	2009-04-10 14:45:59.759503791 +0200
@@ -1466,6 +1466,9 @@
 
 static  gchar  **g_user_special_dirs = NULL;
 
+static  guint  leaked_bytes = 0;
+static  const  guint  max_leaked_bytes = 1024*1024;
+
 /* fifteen minutes of fame for everybody */
 #define G_USER_DIRS_EXPIRE      15 * 60
 
@@ -2471,6 +2482,45 @@
 
 #endif /* G_OS_UNIX && !HAVE_CARBON */
 
+
+void g_reload_user_special_dirs_cache (void)
+{
+    G_LOCK (g_utils_global);
+    int i;
+
+    if (g_user_special_dirs != NULL && leaked_bytes < max_leaked_bytes)
+    {
+        /* save a copy of the pointer, to check if some memory can be preserved */
+        gchar** old_g_user_special_dirs = g_user_special_dirs;
+
+        /* recreate and reload our cache */
+        g_user_special_dirs = g_new0 (gchar *, G_USER_N_DIRECTORIES);
+        load_user_special_dirs ();
+
+        /* only leak changed directories */
+        for (i=0; i<G_USER_N_DIRECTORIES; i++)
+        {
+            if (g_strcmp0(old_g_user_special_dirs[i], g_user_special_dirs[i]) == 0)
+            {
+                /* don't leak */
+                g_free(g_user_special_dirs[i]);
+                g_user_special_dirs[i] = old_g_user_special_dirs[i];
+            }
+            else
+            {
+                /* count how many bytes were leaked */
+                leaked_bytes += sizeof(char) * (1 + strlen(old_g_user_special_dirs[i]));
+            }
+        }
+
+        /* free the old array */
+        g_free(old_g_user_special_dirs);
+    }
+
+    G_UNLOCK(g_utils_global);
+}
+
+
 /**
  * g_get_user_special_dir:
  * @directory: the logical id of special directory
--- glib2.0-2.20.0/glib/gutils.h	2009-03-13 05:09:59.000000000 +0100
+++ glib2.0-2.20.0.new/glib/gutils.h	2009-04-10 14:29:16.572531437 +0200
@@ -127,6 +127,7 @@
 G_CONST_RETURN gchar* g_get_application_name (void);
 void                  g_set_application_name (const gchar *application_name);
 
+void    g_reload_user_special_dirs_cache     (void);
 G_CONST_RETURN gchar*    g_get_user_data_dir      (void);
 G_CONST_RETURN gchar*    g_get_user_config_dir    (void);
 G_CONST_RETURN gchar*    g_get_user_cache_dir     (void);
