[gtk+] gtkicontheme: More explicitly note ownership transfers of duplicated string



commit 703af0fb4892be060bd9d105d9debdc36539aaf1
Author: Colin Walters <walters verbum org>
Date:   Thu May 5 10:13:13 2011 -0400

    gtkicontheme: More explicitly note ownership transfers of duplicated string
    
    I was hunting a memory leak and couldn't find it; at least I'm
    pretty sure all of these are OK.  But document things better
    for the future.
    
    Also use g_hash_table_replace in one more case for consistency.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649457

 gtk/gtkicontheme.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 71ea135..d3471d6 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -1215,9 +1215,10 @@ load_themes (GtkIconTheme *icon_theme)
 		  else
 		    unthemed_icon->no_svg_filename = abs_file;
 
-		  g_hash_table_insert (priv->unthemed_icons,
-				       base_name,
-				       unthemed_icon);
+		  /* takes ownership of base_name */
+		  g_hash_table_replace (priv->unthemed_icons,
+					base_name,
+					unthemed_icon);
 		  g_hash_table_insert (priv->all_icons,
 				       base_name, NULL);
 		}
@@ -2412,6 +2413,7 @@ load_icon_data (IconThemeDir *dir, const char *path, const char *name)
       base_name = strip_suffix (name);
       
       data = g_slice_new0 (GtkIconData);
+      /* takes ownership of base_name */
       g_hash_table_replace (dir->icon_data, base_name, data);
       
       ivalues = g_key_file_get_integer_list (icon_file, 
@@ -2510,6 +2512,7 @@ scan_directory (GtkIconThemePrivate *icon_theme,
 
       hash_suffix = GPOINTER_TO_INT (g_hash_table_lookup (dir->icons, base_name));
       g_hash_table_replace (icon_theme->all_icons, base_name, NULL);
+      /* takes ownership of base_name */
       g_hash_table_replace (dir->icons, base_name, GUINT_TO_POINTER (hash_suffix| suffix));
     }
   



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