[totem-pl-parser/wip/hadess/add-ignored-extensions: 6/13] plparser: Use g_auto* to simplify totem_pl_parser_ignore()
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem-pl-parser/wip/hadess/add-ignored-extensions: 6/13] plparser: Use g_auto* to simplify totem_pl_parser_ignore()
- Date: Sat, 9 Nov 2019 13:17:03 +0000 (UTC)
commit bab470fcdce08ea24eba6327277d8d01bf9dc3aa
Author: Bastien Nocera <hadess hadess net>
Date: Sat Nov 9 13:19:58 2019 +0100
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.
plparse/totem-pl-parser.c | 23 ++++++-----------------
1 file 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]