]> Pileus Git - ~andy/gtk/commitdiff
gtkicontheme: More explicitly note ownership transfers of duplicated string
authorColin Walters <walters@verbum.org>
Thu, 5 May 2011 14:13:13 +0000 (10:13 -0400)
committerColin Walters <walters@verbum.org>
Thu, 5 May 2011 20:02:10 +0000 (16:02 -0400)
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

index 71ea135c317946d628292ff88813a9f2b33d6cb9..d3471d6ee8d412444d87897079a083aa5a15da32 100644 (file)
@@ -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));
     }