summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2019-11-09 13:19:58 +0100
committerBastien Nocera <hadess@hadess.net>2019-11-09 14:16:54 +0100
commitbab470fcdce08ea24eba6327277d8d01bf9dc3aa (patch)
treecddafa9fdc61549c3f1e7af41c6e87497d457bfd
parent1ccb417d47a2494e94b34627c1df303ccdaa7619 (diff)
downloadtotem-pl-parser-bab470fcdce08ea24eba6327277d8d01bf9dc3aa.tar.gz
plparser: Use g_auto* to simplify totem_pl_parser_ignore()
Simplify the exit paths by using g_auto* to free up the mime-type and GFile we allocate.
-rw-r--r--plparse/totem-pl-parser.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index 7203fe8..5c0a8be 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -1604,40 +1604,29 @@ totem_pl_parser_mimetype_is_ignored (TotemPlParser *parser,
gboolean
totem_pl_parser_ignore (TotemPlParser *parser, const char *uri)
{
- char *mimetype;
- GFile *file;
+ g_autofree char *mimetype;
+ g_autoptr(GFile) file;
guint i;
file = g_file_new_for_path (uri);
- if (totem_pl_parser_scheme_is_ignored (parser, file) != FALSE) {
- g_object_unref (file);
+ if (totem_pl_parser_scheme_is_ignored (parser, file) != FALSE)
return TRUE;
- }
- g_object_unref (file);
//FIXME wrong for win32
mimetype = g_content_type_guess (uri, NULL, 0, NULL);
- if (mimetype == NULL || strcmp (mimetype, UNKNOWN_TYPE) == 0) {
- g_free (mimetype);
+ if (mimetype == NULL || strcmp (mimetype, UNKNOWN_TYPE) == 0)
return FALSE;
- }
for (i = 0; i < G_N_ELEMENTS (special_types); i++) {
- if (strcmp (special_types[i].mimetype, mimetype) == 0) {
- g_free (mimetype);
+ if (strcmp (special_types[i].mimetype, mimetype) == 0)
return FALSE;
- }
}
for (i = 0; i < G_N_ELEMENTS (dual_types); i++) {
- if (strcmp (dual_types[i].mimetype, mimetype) == 0) {
- g_free (mimetype);
+ if (strcmp (dual_types[i].mimetype, mimetype) == 0)
return FALSE;
- }
}
- g_free (mimetype);
-
return TRUE;
}