mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-10-05 23:40:01 +00:00
file: simplify get_volume_name and fix leak
`g_mount_get_name` returns a freeable string, so there is no need to duplicate it. Also use g_autoptr to simplify the function.
This commit is contained in:
parent
f17fd617fb
commit
f542b7fc84
|
@ -7382,22 +7382,10 @@ nautilus_file_get_volume_free_space (NautilusFile *file)
|
|||
char *
|
||||
nautilus_file_get_volume_name (NautilusFile *file)
|
||||
{
|
||||
GFile *location;
|
||||
char *res;
|
||||
GMount *mount;
|
||||
g_autoptr (GFile) location = nautilus_file_get_location (file);
|
||||
g_autoptr (GMount) mount = g_file_find_enclosing_mount (location, NULL, NULL);
|
||||
|
||||
res = NULL;
|
||||
|
||||
location = nautilus_file_get_location (file);
|
||||
mount = g_file_find_enclosing_mount (location, NULL, NULL);
|
||||
if (mount)
|
||||
{
|
||||
res = g_strdup (g_mount_get_name (mount));
|
||||
g_object_unref (mount);
|
||||
}
|
||||
g_object_unref (location);
|
||||
|
||||
return res;
|
||||
return mount != NULL ? g_mount_get_name (mount) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue