summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-01-22 13:27:33 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-01-22 13:27:33 +0000
commit5c79eae313fa052aa4fed047d2ac7e5dda4dcd9c (patch)
treeb6b56e19369e333bc0841f9fa12f7ce2d157ea55
parent5269cb7c83dbaad744b498f06af7ef9ab7fda4c1 (diff)
downloadnautilus-5c79eae313fa052aa4fed047d2ac7e5dda4dcd9c.tar.gz
Fix leak of description
2008-01-22 Alexander Larsson <alexl@redhat.com> * libnautilus-private/nautilus-file.c: (get_description): (update_description_for_link): Fix leak of description * libnautilus-private/nautilus-metafile.c: (set_metafile_contents): fix leak of xmlName. svn path=/trunk/; revision=13636
-rw-r--r--ChangeLog11
-rw-r--r--libnautilus-private/nautilus-file.c43
-rw-r--r--libnautilus-private/nautilus-metafile.c3
3 files changed, 26 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 6225c6087..07b3721f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2008-01-22 Alexander Larsson <alexl@redhat.com>
+ * libnautilus-private/nautilus-file.c:
+ (get_description):
+ (update_description_for_link):
+ Fix leak of description
+
+ * libnautilus-private/nautilus-metafile.c:
+ (set_metafile_contents):
+ fix leak of xmlName.
+
+2008-01-22 Alexander Larsson <alexl@redhat.com>
+
* libnautilus-private/apps_nautilus_preferences.schemas.in:
* libnautilus-private/nautilus-file-operations.c:
* src/Nautilus_shell.server.in:
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 7d9907653..332ace915 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -5263,12 +5263,11 @@ nautilus_file_get_string_attribute_with_default (NautilusFile *file, const char
* Returns: Newly allocated string ready to display to the user.
*
**/
-
-static const char *
+static char *
get_description (NautilusFile *file)
{
- const char *mime_type, *description;
- static GHashTable *warned = NULL;
+ const char *mime_type;
+ char *description;
g_assert (NAUTILUS_IS_FILE (file));
@@ -5279,7 +5278,7 @@ get_description (NautilusFile *file)
if (g_content_type_is_unknown (mime_type) &&
nautilus_file_is_executable (file)) {
- return _("program");
+ return g_strdup (_("program"));
}
description = g_content_type_get_description (mime_type);
@@ -5287,33 +5286,15 @@ get_description (NautilusFile *file)
return description;
}
- if (warned == NULL) {
- warned = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- eel_debug_call_at_shutdown_with_data ((GFreeFunc)g_hash_table_destroy, warned);
- }
-
- /* We want to update gnome-vfs/data/mime/gnome-vfs.keys to include
- * English (& localizable) versions of every mime type anyone ever sees.
- */
- if (!g_hash_table_lookup (warned, mime_type)) {
- if (g_ascii_strcasecmp (mime_type, "x-directory/normal") == 0) {
- g_warning (_("Can't find description even for \"x-directory/normal\". This "
- "probably means that your gnome-vfs.keys file is in the wrong place "
- "or isn't being found for some other reason."));
- } else {
- g_warning (_("No description found for mime type \"%s\" (file is \"%s\"), "
- "please tell the gnome-vfs mailing list."),
- mime_type,
- eel_ref_str_peek (file->details->name));
- }
- g_hash_table_insert (warned, g_strdup (mime_type), GINT_TO_POINTER (1));
- }
- return mime_type;
+ return g_strdup (mime_type);
}
+/* Takes ownership of string */
static char *
-update_description_for_link (NautilusFile *file, const char *string)
+update_description_for_link (NautilusFile *file, char *string)
{
+ char *res;
+
if (nautilus_file_is_symbolic_link (file)) {
g_assert (!nautilus_file_is_broken_symbolic_link (file));
if (string == NULL) {
@@ -5323,10 +5304,12 @@ update_description_for_link (NautilusFile *file, const char *string)
* (e.g. "folder", "plain text") to file type for symbolic link
* to that kind of file (e.g. "link to folder").
*/
- return g_strdup_printf (_("Link to %s"), string);
+ res = g_strdup_printf (_("Link to %s"), string);
+ g_free (string);
+ return res;
}
- return g_strdup (string);
+ return string;
}
static char *
diff --git a/libnautilus-private/nautilus-metafile.c b/libnautilus-private/nautilus-metafile.c
index c1fe9edbd..3ad971f37 100644
--- a/libnautilus-private/nautilus-metafile.c
+++ b/libnautilus-private/nautilus-metafile.c
@@ -1698,10 +1698,11 @@ set_metafile_contents (NautilusMetafile *metafile,
if (strcmp (node->name, "file") == 0) {
name = xmlGetProp (node, "name");
unescaped_name = g_uri_unescape_string (name, "/");
+ xmlFree (name);
if (unescaped_name == NULL ||
g_hash_table_lookup (hash, unescaped_name) != NULL) {
- xmlFree (name);
/* FIXME: Should we delete duplicate nodes as we discover them? */
+ g_free (unescaped_name);
} else {
g_hash_table_insert (hash, unescaped_name, node);
}