[gtk: 1/2] language-names: Do not g_free() a GError
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/2] language-names: Do not g_free() a GError
- Date: Thu, 17 Sep 2020 23:34:05 +0000 (UTC)
commit 50f373fbc2a238a013e7f84de8431741dc388c7a
Author: Peter Bloomfield <peterbloomfield bellsouth net>
Date: Thu Sep 17 23:34:03 2020 +0000
language-names: Do not g_free() a GError
It's NULL anyway, so freeing GError with g_free() when it's allocated with
GSlice never actually happens, but it just looks bad.
gtk/language-names.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/gtk/language-names.c b/gtk/language-names.c
index dd9ec7e5fb..8928366ab7 100644
--- a/gtk/language-names.c
+++ b/gtk/language-names.c
@@ -179,9 +179,9 @@ languages_variant_init (const char *variant)
{
gboolean res;
gsize buf_len;
- char *buf = NULL;
- char *filename = NULL;
- GError *error = NULL;
+ char *buf;
+ char *filename;
+ GError *error;
bindtextdomain (variant, ISO_CODES_LOCALESDIR);
bind_textdomain_codeset (variant, "UTF-8");
@@ -196,16 +196,20 @@ languages_variant_init (const char *variant)
ctx = g_markup_parse_context_new (&parser, 0, NULL, NULL);
- g_free (error);
- error = NULL;
res = g_markup_parse_context_parse (ctx, buf, buf_len, &error);
g_free (ctx);
if (!res)
- g_warning ("Failed to parse '%s': %s\n", filename, error->message);
+ {
+ g_warning ("Failed to parse '%s': %s\n", filename, error->message);
+ g_error_free (error);
+ }
}
else
- g_warning ("Failed to load '%s': %s\n", filename, error->message);
+ {
+ g_warning ("Failed to load '%s': %s\n", filename, error->message);
+ g_error_free (error);
+ }
g_free (filename);
g_free (buf);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]