[goffice] Utils: plug leak
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Utils: plug leak
- Date: Mon, 21 Nov 2011 21:03:34 +0000 (UTC)
commit 0cc0c63c67913fdb02ed04b2ee3360316c206500
Author: Morten Welinder <terra gnome org>
Date: Mon Nov 21 16:03:19 2011 -0500
Utils: plug leak
goffice/goffice.c | 1 +
goffice/utils/go-glib-extras.c | 16 +++++++++++-----
goffice/utils/go-glib-extras.h | 2 ++
3 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/goffice/goffice.c b/goffice/goffice.c
index 550af71..52853a2 100644
--- a/goffice/goffice.c
+++ b/goffice/goffice.c
@@ -236,6 +236,7 @@ libgoffice_shutdown (void)
if (--initialized)
return;
_gog_themes_shutdown ();
+ _go_glib_extras_shutdown ();
_go_fonts_shutdown ();
_go_conf_shutdown ();
#ifdef GOFFICE_WITH_GTK
diff --git a/goffice/utils/go-glib-extras.c b/goffice/utils/go-glib-extras.c
index 8c9175d..db2f224 100644
--- a/goffice/utils/go-glib-extras.c
+++ b/goffice/utils/go-glib-extras.c
@@ -73,7 +73,7 @@ go_ptr_array_insert (GPtrArray *array, gpointer value, int index)
/**
* go_slist_create:
- * @item1: itionally %NULL
+ * @item1: optionally %NULL
* @Varargs : %NULL terminated list of additional items
*
* Creates a GList from NULL-terminated list of arguments.
@@ -709,6 +709,8 @@ go_guess_encoding (const char *raw, size_t len, const char *user_guess,
}
}
+static char *go_real_name = NULL;
+
/**
* go_get_real_name :
*
@@ -718,9 +720,6 @@ go_guess_encoding (const char *raw, size_t len, const char *user_guess,
char const *
go_get_real_name (void)
{
- /* We will leak this. */
- static char *go_real_name = NULL;
-
if (go_real_name == NULL) {
char const *name = getenv ("NAME");
if (name == NULL)
@@ -735,7 +734,7 @@ go_get_real_name (void)
go_real_name = g_string_free (converted_name, FALSE);
}
if (go_real_name == NULL)
- go_real_name = (char *)"unknown";
+ go_real_name = g_strdup ("unknown");
}
return go_real_name;
}
@@ -1029,3 +1028,10 @@ syntax:
res = TRUE;
goto done;
}
+
+void
+_go_glib_extras_shutdown (void)
+{
+ g_free (go_real_name);
+ go_real_name = NULL;
+}
diff --git a/goffice/utils/go-glib-extras.h b/goffice/utils/go-glib-extras.h
index c8f3737..150813b 100644
--- a/goffice/utils/go-glib-extras.h
+++ b/goffice/utils/go-glib-extras.h
@@ -112,6 +112,8 @@ gboolean go_parse_key_value (const char *options,
GOParseKeyValueFunc handler,
gpointer user);
+void _go_glib_extras_shutdown (void);
+
G_END_DECLS
#endif /* GO_GLIB_EXTRAS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]