gnome-menus r882 - in trunk: . libmenu



Author: vuntz
Date: Tue Apr 15 17:24:14 2008
New Revision: 882
URL: http://svn.gnome.org/viewvc/gnome-menus?rev=882&view=rev

Log:
2008-04-15  Vincent Untz  <vuntz gnome org>

	* libmenu/entry-directories.c: (cached_dir_add_subdir),
	(cached_dir_remove_subdir): reuse find_subdir() to simplify code
	Based on patch in bug #349695, by William Jon McCann <mccann jhu edu>
	* libmenu/gmenu-tree.c: (add_menu_for_legacy_dir): fix leak


Modified:
   trunk/ChangeLog
   trunk/libmenu/entry-directories.c
   trunk/libmenu/gmenu-tree.c

Modified: trunk/libmenu/entry-directories.c
==============================================================================
--- trunk/libmenu/entry-directories.c	(original)
+++ trunk/libmenu/entry-directories.c	Tue Apr 15 17:24:14 2008
@@ -314,20 +314,13 @@
                        const char *path)
 {
   CachedDir *subdir;
-  GSList    *tmp;
 
-  tmp = dir->subdirs;
-  while (tmp != NULL)
-    {
-      subdir = (CachedDir *) tmp->data;
-
-      if (strcmp (subdir->name, basename) == 0)
-        {
-	  subdir->deleted = FALSE;
-          return TRUE;
-        }
+  subdir = find_subdir (dir, basename);
 
-      tmp = tmp->next;
+  if (subdir != NULL)
+    {
+      subdir->deleted = FALSE;
+      return TRUE;
     }
 
   subdir = cached_dir_new (basename);
@@ -350,27 +343,21 @@
 cached_dir_remove_subdir (CachedDir  *dir,
                           const char *basename)
 {
-  GSList *tmp;
+  CachedDir *subdir;
 
-  tmp = dir->subdirs;
-  while (tmp != NULL)
+  subdir = find_subdir (dir, basename);
+
+  if (subdir != NULL)
     {
-      CachedDir *subdir = tmp->data;
+      subdir->deleted = TRUE;
 
-      if (strcmp (subdir->name, basename) == 0)
+      if (subdir->references == 0)
         {
-	  subdir->deleted = TRUE;
-
-	  if (subdir->references == 0)
-	    {
-	      cached_dir_free (subdir);
-	      dir->subdirs = g_slist_delete_link (dir->subdirs, tmp);
-	    }
-
-          return TRUE;
+          cached_dir_free (subdir);
+          dir->subdirs = g_slist_remove (dir->subdirs, subdir);
         }
 
-      tmp = tmp->next;
+      return TRUE;
     }
 
   return FALSE;

Modified: trunk/libmenu/gmenu-tree.c
==============================================================================
--- trunk/libmenu/gmenu-tree.c	(original)
+++ trunk/libmenu/gmenu-tree.c	Tue Apr 15 17:24:14 2008
@@ -2212,6 +2212,7 @@
         }
 
       g_string_free (subdir_path, TRUE);
+      g_string_free (subdir_relative, TRUE);
 
       menu_layout_node_unref (menu);
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]