[glib/wip/gcleanup] gcleanup: Hookup up more libglib globals to cleanup
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup] gcleanup: Hookup up more libglib globals to cleanup
- Date: Thu, 7 Nov 2013 22:02:46 +0000 (UTC)
commit fb7b0feb790d52d5be1a7ad4006ad441fbb677f7
Author: Stef Walter <stefw gnome org>
Date: Thu Nov 7 22:38:05 2013 +0100
gcleanup: Hookup up more libglib globals to cleanup
glib/gcharset.c | 1 +
glib/gdataset.c | 1 +
glib/gdate.c | 18 +++++++++++++++++-
glib/gquark.c | 7 +++----
glib/gtestutils.c | 4 ++++
glib/gtimezone.c | 5 ++++-
glib/gutils.c | 6 ++----
7 files changed, 32 insertions(+), 10 deletions(-)
---
diff --git a/glib/gcharset.c b/glib/gcharset.c
index cdbc357..4cf7e67 100644
--- a/glib/gcharset.c
+++ b/glib/gcharset.c
@@ -51,6 +51,7 @@ get_alias_hash (void)
if (!alias_hash)
{
alias_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ G_CLEANUP (alias_hash, g_hash_table_unref);
aliases = _g_locale_get_charset_aliases ();
while (*aliases != '\0')
diff --git a/glib/gdataset.c b/glib/gdataset.c
index 006bdc1..b2a8eca 100644
--- a/glib/gdataset.c
+++ b/glib/gdataset.c
@@ -1240,5 +1240,6 @@ g_data_initialize (void)
g_return_if_fail (g_dataset_location_ht == NULL);
g_dataset_location_ht = g_hash_table_new (g_direct_hash, NULL);
+ G_CLEANUP (g_dataset_location_ht, g_hash_table_unref);
g_dataset_cached = NULL;
}
diff --git a/glib/gdate.c b/glib/gdate.c
index 1978cf7..f5cd53d 100644
--- a/glib/gdate.c
+++ b/glib/gdate.c
@@ -889,6 +889,19 @@ typedef struct _GDateParseTokens GDateParseTokens;
#define NUM_LEN 10
+static void
+g_date_cleanup (void)
+{
+ int i;
+
+ for (i = 1; i <= 12; i++)
+ {
+ g_clear_pointer (&short_month_names[i], g_free);
+ g_clear_pointer (&long_month_names[i], g_free);
+ }
+ g_clear_pointer (¤t_locale, g_free);
+}
+
/* HOLDS: g_date_global_lock */
static void
g_date_fill_parse_tokens (const gchar *str, GDateParseTokens *pt)
@@ -985,7 +998,10 @@ g_date_prepare_to_parse (const gchar *str,
g_return_if_fail (locale != NULL); /* should not happen */
g_date_clear (&d, 1); /* clear for scratch use */
-
+
+ if (current_locale == NULL)
+ G_CLEANUP_FUNC (g_date_cleanup);
+
if ( (current_locale == NULL) || (strcmp (locale, current_locale) != 0) )
recompute_localeinfo = TRUE; /* Uh, there used to be a reason for the temporary */
diff --git a/glib/gquark.c b/glib/gquark.c
index 9762dd6..9c82514 100644
--- a/glib/gquark.c
+++ b/glib/gquark.c
@@ -152,6 +152,7 @@ quark_strdup (const gchar *string)
QUARK_STRING_BLOCK_SIZE - quark_block_offset < len)
{
quark_block = g_malloc (QUARK_STRING_BLOCK_SIZE);
+ G_CLEANUP_LATE (quark_block, g_free);
quark_block_offset = 0;
}
@@ -279,10 +280,7 @@ quark_new (gchar *string)
if (quark_seq_id != 0)
memcpy (quarks_new, quarks, sizeof (char *) * quark_seq_id);
memset (quarks_new + quark_seq_id, 0, sizeof (char *) * QUARK_BLOCK_SIZE);
- /* This leaks the old quarks array. Its unfortunate, but it allows
- * us to do lockless lookup of the arrays, and there shouldn't be that
- * many quarks in an app
- */
+ G_CLEANUP_LATE (quarks_new, g_free);
g_atomic_pointer_set (&quarks, quarks_new);
}
if (!quark_ht)
@@ -291,6 +289,7 @@ quark_new (gchar *string)
quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
quarks[quark_seq_id] = NULL;
g_atomic_int_inc (&quark_seq_id);
+ G_CLEANUP_LATE (quark_ht, g_hash_table_unref);
}
quark = quark_seq_id;
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index ddaf47f..918c0fe 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -1027,6 +1027,10 @@ g_test_cleanup (void)
g_free (test_trap_last_stdout);
g_free (test_trap_last_stderr);
g_free (test_uri_base);
+ g_free (test_initial_cwd);
+
+ if (test_user_timer)
+ g_timer_destroy (test_user_timer);
}
/**
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index f93c825..671edd8 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -1379,7 +1379,10 @@ g_time_zone_new (const gchar *identifier)
G_LOCK (time_zones);
if (time_zones == NULL)
- time_zones = g_hash_table_new (g_str_hash, g_str_equal);
+ {
+ time_zones = g_hash_table_new (g_str_hash, g_str_equal);
+ G_CLEANUP (time_zones, g_hash_table_unref);
+ }
if (identifier)
{
diff --git a/glib/gutils.c b/glib/gutils.c
index 183f5fe..9e84278 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -1143,12 +1143,9 @@ void
g_set_prgname (const gchar *prgname)
{
G_LOCK (g_prgname);
- /* We want to use remove here because this is a leak and we want that
- * to show up in valgrind, so we should _not_ free the original string
- * during cleanup.
- */
if (!g_prgname)
G_CLEANUP_FUNC (cleanup_prgname);
+ g_free (g_prgname);
g_prgname = g_strdup (prgname);
G_UNLOCK (g_prgname);
}
@@ -2056,6 +2053,7 @@ g_get_system_data_dirs (void)
#endif
g_system_data_dirs = data_dir_vector;
+ G_CLEANUP (g_system_data_dirs, g_strfreev);
}
else
data_dir_vector = g_system_data_dirs;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]