[glib/wip/gcleanup: 21/21] gcleanup: Rework for distinct phases
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup: 21/21] gcleanup: Rework for distinct phases
- Date: Thu, 7 Nov 2013 07:22:24 +0000 (UTC)
commit 9bda5972a9de323f1cd7518ebdd50fac64347221
Author: Stef Walter <stefw gnome org>
Date: Thu Nov 7 08:16:30 2013 +0100
gcleanup: Rework for distinct phases
WIP
This has explicit debug code, which will be removed before committing.
This'll probably be squashed/merged with other commits.
glib/Makefile.am | 1 +
glib/gcharset.c | 2 +-
glib/gcleanup.c | 194 ++++++++++++++++++++++++++++++++++----------------
glib/gcleanup.h | 68 ++++++++++++------
glib/gmain.c | 4 +-
glib/grand.c | 2 +-
glib/gtestutils.c | 2 +-
glib/gthread-posix.c | 41 ++++-------
glib/gthread.h | 6 +-
glib/gutils.c | 28 ++++----
10 files changed, 215 insertions(+), 133 deletions(-)
---
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 9c3c19e..05360d8 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -38,6 +38,7 @@ AM_CPPFLAGS = \
$(glib_INCLUDES) \
$(pcre_inc) \
-DG_LOG_DOMAIN=\"GLib\" \
+ -DG_CLEANUP_MODULE=glib \
$(GLIB_DEBUG_FLAGS) \
-DGLIB_COMPILATION \
-DPCRE_STATIC
diff --git a/glib/gcharset.c b/glib/gcharset.c
index 62aa566..cdbc357 100644
--- a/glib/gcharset.c
+++ b/glib/gcharset.c
@@ -243,7 +243,7 @@ read_aliases (gchar *file)
if (!alias_table)
{
alias_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- G_CLEANUP_ADD (alias_table, g_hash_table_unref);
+ G_CLEANUP (alias_table, g_hash_table_unref);
}
fp = fopen (file,"r");
diff --git a/glib/gcleanup.c b/glib/gcleanup.c
index 55c2df5..e8e9d70 100644
--- a/glib/gcleanup.c
+++ b/glib/gcleanup.c
@@ -24,43 +24,65 @@
#include "gcleanup.h"
#include "glib-init.h"
-#include "gthread.h"
+#include "gmessages.h"
+#include "gatomic.h"
#include <stdlib.h>
/*
* NOTE: most glib functions are off limits in this function without
- * careful consideration. In particular error printing and logging functions,
+ * careful consideration. In particular logging functions,
* use various locks, which would cause issues during cleanup.
*
*/
-/*
- * The gcleanup code has four passes.
- *
- * This is so things that need to absolutely be cleaned up last, add
- * themselves to the next pass from within their cleanup handler. These
- * are used for GMutex, GPrivate and so on.
- */
-
-#ifndef GLIB_CLEANUP_PASSES
-#define GLIB_CLEANUP_PASSES 4
-#endif
-
#include <stdio.h>
+#define MAX_PASSES 3
+
/* As good a place as any to put this... */
-G_CLEANUP_DEFINE (G_CLEANUP_NORMAL);
+G_CLEANUP_DEFINE
typedef struct _GCleanupNode GCleanupNode;
struct _GCleanupNode
{
GDestroyNotify func;
gpointer data;
- const gchar *code_loc;
+ GCleanupPhase phase;
+ const gchar *location;
GCleanupNode *next;
};
+/* indexes into list->priv */
+enum {
+ P_NODES = 0,
+ P_LOG = 1,
+};
+
+/* indexes into list->vals */
+enum {
+ V_FLAGS = 0,
+ V_PHASE = 1,
+};
+
+static const gchar *
+phase_to_string (GCleanupPhase phase)
+{
+ switch (phase)
+ {
+ case G_CLEANUP_PHASE_EARLY:
+ return "early";
+ case G_CLEANUP_PHASE_MAIN:
+ return "main";
+ case G_CLEANUP_PHASE_LATE:
+ return "late";
+ case G_CLEANUP_PHASE_GRAVEYARD:
+ return "graveyard";
+ default:
+ return "unknown";
+ }
+}
+
/**
* g_cleanup_is_enabled:
*
@@ -88,6 +110,7 @@ g_cleanup_is_enabled (void)
* @list: a #GCleanupList
* @cleanup_func: the cleanup function
* @user_data: data for the cleanup function
+ * @tail_cleanup: run this function at the end of cleanup phase
* @code_loc: (allow-none): static string representing location of this call (ie: G_STRLOC)
*
* Adds a function to @list.
@@ -96,7 +119,7 @@ g_cleanup_is_enabled (void)
* called with @user_data.
*
* Most typically, you will not use this function directly. See
- * G_CLEANUP_ADD() or G_CLEANUP_ADD_FUNC().
+ * G_CLEANUP(), G_CLEANUP_LATE() or G_CLEANUP_FUNC().
*
* This function is threadsafe. Multiple threads can add to the same
* list at the same time.
@@ -104,31 +127,79 @@ g_cleanup_is_enabled (void)
* Since: 2.40
**/
void
-g_cleanup_list_add (GCleanupList *list,
- GCleanupFunc cleanup_func,
- gpointer user_data,
- const gchar *code_loc)
+g_cleanup_list_push (GCleanupList *list,
+ GCleanupFunc cleanup_func,
+ gpointer user_data,
+ GCleanupPhase phase,
+ const gchar *location)
{
GCleanupNode *node;
g_return_if_fail (cleanup_func != NULL);
- if (!g_cleanup_enabled)
+ if (!list || !g_cleanup_enabled)
return;
+ g_return_if_fail (phase >= g_atomic_int_get (&list->vals[V_PHASE]));
+
node = malloc (sizeof (GCleanupNode));
node->func = cleanup_func;
node->data = user_data;
- node->code_loc = code_loc;
+ node->location = location;
+ node->phase = phase;
do
{
- node->next = list->priv[0];
+ node->next = list->priv[P_NODES];
}
- while (!g_atomic_pointer_compare_and_exchange (&list->priv[0], node->next, node));
+ while (!g_atomic_pointer_compare_and_exchange (&list->priv[P_NODES],
+ node->next, node));
- if (list->vals[0] & G_CLEANUP_VERBOSE)
- fprintf (stderr, "GLib-Cleanup: added: %s %p\n", code_loc, user_data);
+ fprintf (stderr, "g_cleanup_list_push: pushed %p/%s at %s\n", user_data, phase_to_string (phase),
location);
+}
+
+static GCleanupNode *
+cleanup_pass (GCleanupList *list,
+ GCleanupNode *clear,
+ GCleanupNode *also,
+ GCleanupPhase phase,
+ gboolean *cleaned_up)
+{
+ GCleanupNode *later;
+ GCleanupNode **later_next;
+ GCleanupNode *node;
+
+ later = NULL;
+ later_next = &later;
+
+ while (clear || also)
+ {
+ if (!clear && also)
+ {
+ clear = also;
+ also = NULL;
+ }
+
+ node = clear;
+ clear = node->next;
+
+ if (node->phase > phase)
+ {
+ node->next = NULL;
+ *later_next = node;
+ later_next = &node->next;
+ fprintf (stderr, "g_cleanup_list_clear: delaying till %s: %p at %s\n", phase_to_string
(node->phase), node->data, node->location);
+ }
+ else
+ {
+ fprintf (stderr, "g_cleanup_list_clear: cleanup at %s: %p at %s\n", phase_to_string (node->phase),
node->data, node->location);
+ (*node->func) (node->data);
+ *cleaned_up = TRUE;
+ free (node);
+ }
+ }
+
+ return later;
}
/**
@@ -148,58 +219,55 @@ g_cleanup_list_add (GCleanupList *list,
void
g_cleanup_list_clear (GCleanupList *list)
{
- gboolean verbose;
+ GCleanupNode *later;
GCleanupNode *clear;
+ GCleanupPhase phase;
+ gboolean progressed;
gint i;
- if (!g_cleanup_enabled)
+ if (!list || !g_cleanup_enabled)
return;
- verbose = list->vals[0] & G_CLEANUP_VERBOSE;
- for (i = 0; i < GLIB_CLEANUP_PASSES + 1; i++)
+ /* Note that we're starting to clear */
+ phase = G_CLEANUP_PHASE_EARLY;
+ if (!g_atomic_int_compare_and_exchange (&list->vals[V_PHASE], 0, phase))
{
- do
- {
- /* Steal the list pointer */
- clear = list->priv[0];
- }
- while (!g_atomic_pointer_compare_and_exchange (&list->priv[0], clear, NULL));
+ g_critical ("g_cleanup_list_clear() called twice for the same GCleanupList");
+ return;
+ }
- if (!clear)
- {
- if (verbose)
- fprintf (stderr, "GLib-Cleanup: cleanup done\n");
- break;
- }
+ later = NULL;
- if (i == GLIB_CLEANUP_PASSES)
- {
- fprintf (stderr, "GLib-Cleanup: gave up after %d passes\n", GLIB_CLEANUP_PASSES);
- }
- else if (i > 0)
+ while (phase <= G_CLEANUP_PHASE_GRAVEYARD)
+ {
+ fprintf (stderr, "g_cleanup_list_clear: at phase %s\n", phase_to_string (phase));
+ for (i = 0; i < MAX_PASSES + 1; i++)
{
- if (verbose)
- fprintf (stderr, "GLib-Cleanup: performing pass %d\n", i + 1);
- }
-
+ progressed = FALSE;
- while (clear)
- {
- GCleanupNode *node = clear;
- if (i == GLIB_CLEANUP_PASSES)
+ do
{
- fprintf (stderr, "GLib-Cleanup: ignoring cleanup for: %s %p\n", node->code_loc, node->data);
+ /* Steal the list pointer */
+ clear = list->priv[P_NODES];
}
- else
+ while (!g_atomic_pointer_compare_and_exchange (&list->priv[P_NODES], clear, NULL));
+
+ if (clear && i == MAX_PASSES)
{
- if (verbose)
- fprintf (stderr, "GLib-Cleanup: cleanup: %s %p\n", node->code_loc, node->data);
- (* node->func) (node->data);
+ fprintf (stderr, "g_cleanup_list_clear: gave up after %d passes\n", MAX_PASSES);
+ return;
}
- clear = node->next;
- free (node);
+
+ later = cleanup_pass (list, clear, later, phase, &progressed);
+
+ if (!progressed)
+ break;
}
+
+ phase = g_atomic_int_add (&list->vals[V_PHASE], 1) + 1;
}
+
+ fprintf (stderr, "g_cleanup_list_clear: cleanup done\n");
}
/**
diff --git a/glib/gcleanup.h b/glib/gcleanup.h
index 1f72afd..5f7b85e 100644
--- a/glib/gcleanup.h
+++ b/glib/gcleanup.h
@@ -39,54 +39,80 @@ typedef struct
typedef enum
{
- G_CLEANUP_NORMAL = 0,
- G_CLEANUP_VERBOSE = 1 << 0,
-} GCleanupFlags;
+ G_CLEANUP_PHASE_EARLY = 1,
+ G_CLEANUP_PHASE_MAIN = 2,
+ G_CLEANUP_PHASE_LATE = 3,
+ G_CLEANUP_PHASE_GRAVEYARD = 4,
+} GCleanupPhase;
typedef void (* GCleanupFunc) (gpointer user_data);
GLIB_AVAILABLE_IN_2_40
gboolean g_cleanup_is_enabled (void);
GLIB_AVAILABLE_IN_2_40
-void g_cleanup_list_add (GCleanupList *list,
+void g_cleanup_list_push (GCleanupList *list,
GCleanupFunc cleanup_func,
gpointer user_data,
- const gchar * code_loc);
+ GCleanupPhase phase,
+ const gchar *location);
GLIB_AVAILABLE_IN_2_40
void g_cleanup_list_clear (GCleanupList *list);
+#if defined(G_HAS_CONSTRUCTORS) && !defined(G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA) && defined(G_CLEANUP_MODULE)
-#if defined(G_HAS_CONSTRUCTORS) && !defined(G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA)
+extern GCleanupList G_PASTE(G_CLEANUP_MODULE, _cleanup_list);
-#define G_CLEANUP_DEFINE(flags) \
- GCleanupList _glib_cleanup_list = { { 0, }, { flags, } }; \
- G_DEFINE_DESTRUCTOR (_glib_do_cleanup) \
- static void _glib_do_cleanup (void) { \
- g_cleanup_list_clear (&_glib_cleanup_list); \
+#define G_CLEANUP_LIST \
+ (&G_PASTE (G_CLEANUP_MODULE, _cleanup_list))
+#define G_CLEANUP_DEFINE \
+ GCleanupList G_PASTE(G_CLEANUP_MODULE, _cleanup_list) = \
+ { { 0, G_LOG_DOMAIN, }, { 0, } }; \
+ G_DEFINE_DESTRUCTOR (G_PASTE (G_CLEANUP_MODULE, _cleanup_perform)) \
+ static void G_PASTE (G_CLEANUP_MODULE, _cleanup_perform) (void) { \
+ g_cleanup_list_clear (G_CLEANUP_LIST); \
}
-#define G_CLEANUP_ADD(data, func) \
+#define G_CLEANUP(data, func) \
G_STMT_START { \
- extern GCleanupList _glib_cleanup_list; \
if (0) (func) ((data)); \
- g_cleanup_list_add (&_glib_cleanup_list, (void*) (func), (data), \
- G_STRLOC ": " G_STRINGIFY (func)); \
+ g_cleanup_list_push (G_CLEANUP_LIST, (void*) (func), (data), \
+ G_CLEANUP_PHASE_MAIN, G_STRLOC ": " G_STRINGIFY (func)); \
} G_STMT_END
-#define G_CLEANUP_ADD_FUNC(func) \
+#define G_CLEANUP_LATE(data, func) \
+ G_STMT_START { \
+ if (0) (func) ((data)); \
+ g_cleanup_list_push (G_CLEANUP_LIST, (void*) (func), (data), \
+ G_CLEANUP_PHASE_LATE, G_STRLOC ": " G_STRINGIFY (func));\
+ } G_STMT_END
+#define G_CLEANUP_FUNC(func) \
+ G_STMT_START { \
+ if (0) (func) (); \
+ g_cleanup_list_push (G_CLEANUP_LIST, (void*) (func), NULL, \
+ G_CLEANUP_PHASE_MAIN, G_STRLOC ": " G_STRINGIFY (func)); \
+ } G_STMT_END
+#define G_CLEANUP_LATE_FUNC(func) \
G_STMT_START { \
- extern GCleanupList _glib_cleanup_list; \
if (0) (func) (); \
- g_cleanup_list_add (&_glib_cleanup_list, (void*) (func), NULL, \
- G_STRLOC ": " G_STRINGIFY (func)); \
+ g_cleanup_list_push (G_CLEANUP_LIST, (void*) (func), NULL, \
+ G_CLEANUP_PHASE_LATE, G_STRLOC ": " G_STRINGIFY (func));\
} G_STMT_END
#else
+#define G_CLEANUP_LIST NULL
#define G_CLEANUP_DEFINE(flags)
-#define G_CLEANUP_ADD(data, func) \
+#define G_CLEANUP(data, func) \
G_STMT_START { \
if (0) (func) (data); \
} G_STMT_END
-#define G_CLEANUP_ADD_FUNC(func) \
+#define G_CLEANUP_LATE(data, func) \
+ G_STMT_START { \
+ if (0) (func) (data); \
+ } G_STMT_END
+#define G_CLEANUP_FUNC(func) \
+ G_STMT_START { \
+ if (0) (func) (); \
+ } G_STMT_END
+#define G_CLEANUP_LATE_FUNC(func) \
G_STMT_START { \
if (0) (func) (); \
} G_STMT_END
diff --git a/glib/gmain.c b/glib/gmain.c
index e2296e7..5f16f6d 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -656,7 +656,7 @@ g_main_context_default (void)
if (_g_main_poll_debug)
g_print ("default context=%p\n", default_main_context);
#endif
- G_CLEANUP_ADD (default_main_context, g_main_context_unref);
+ G_CLEANUP (default_main_context, g_main_context_unref);
}
G_UNLOCK (main_loop);
@@ -5520,7 +5520,7 @@ g_get_worker_context (void)
pthread_sigmask (SIG_SETMASK, &prev_mask, NULL);
#endif
- G_CLEANUP_ADD_FUNC (glib_worker_kill);
+ G_CLEANUP_FUNC (glib_worker_kill);
g_once_init_leave (&initialised, TRUE);
}
diff --git a/glib/grand.c b/glib/grand.c
index b7d241c..ab74983 100644
--- a/glib/grand.c
+++ b/glib/grand.c
@@ -606,7 +606,7 @@ get_global_random (void)
if (!global_random)
{
global_random = g_rand_new ();
- G_CLEANUP_ADD (global_random, g_rand_free);
+ G_CLEANUP (global_random, g_rand_free);
}
return global_random;
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 54b63f0..ddaf47f 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -1188,7 +1188,7 @@ g_test_init (int *argc,
if (!test_built_files_dir)
test_built_files_dir = test_argv0_dirname;
- G_CLEANUP_ADD_FUNC (g_test_cleanup);
+ G_CLEANUP_FUNC (g_test_cleanup);
}
static void
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index c7c7c76..43d7981 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -119,13 +119,6 @@ g_mutex_impl_free (pthread_mutex_t *mutex)
free (mutex);
}
-static void
-g_mutex_impl_cleanup (pthread_mutex_t *mutex)
-{
- /* Do mutexes near the end, so other cleanup can use them */
- G_CLEANUP_ADD (mutex, g_mutex_impl_free);
-}
-
static pthread_mutex_t *
g_mutex_get_impl (GMutex *mutex)
{
@@ -135,7 +128,8 @@ g_mutex_get_impl (GMutex *mutex)
{
impl = g_mutex_impl_new ();
if (g_atomic_pointer_compare_and_exchange (&mutex->p, NULL, impl))
- G_CLEANUP_ADD (impl, g_mutex_impl_cleanup);
+ g_cleanup_list_push (G_CLEANUP_LIST, (GCleanupFunc)g_mutex_impl_free, impl,
+ G_CLEANUP_PHASE_GRAVEYARD, G_STRFUNC);
else
g_mutex_impl_free (impl);
impl = mutex->p;
@@ -304,7 +298,7 @@ static void
g_rec_mutex_impl_cleanup (pthread_mutex_t *mutex)
{
/* Perform actual cleanup in the next pass */
- G_CLEANUP_ADD (mutex, g_rec_mutex_impl_free);
+ G_CLEANUP (mutex, g_rec_mutex_impl_free);
}
static pthread_mutex_t *
@@ -316,7 +310,8 @@ g_rec_mutex_get_impl (GRecMutex *rec_mutex)
{
impl = g_rec_mutex_impl_new ();
if (g_atomic_pointer_compare_and_exchange (&rec_mutex->p, NULL, impl))
- G_CLEANUP_ADD (impl, g_rec_mutex_impl_cleanup);
+ g_cleanup_list_push (G_CLEANUP_LIST, (GCleanupFunc)g_rec_mutex_impl_cleanup, impl,
+ G_CLEANUP_PHASE_GRAVEYARD, G_STRFUNC);
else
g_rec_mutex_impl_free (impl);
impl = rec_mutex->p;
@@ -469,12 +464,6 @@ g_rw_lock_impl_free (pthread_rwlock_t *rwlock)
free (rwlock);
}
-static void
-g_rw_lock_impl_cleanup (pthread_rwlock_t *rwlock)
-{
- G_CLEANUP_ADD (rwlock, g_rw_lock_impl_free);
-}
-
static pthread_rwlock_t *
g_rw_lock_get_impl (GRWLock *lock)
{
@@ -484,7 +473,8 @@ g_rw_lock_get_impl (GRWLock *lock)
{
impl = g_rw_lock_impl_new ();
if (g_atomic_pointer_compare_and_exchange (&lock->p, NULL, impl))
- G_CLEANUP_ADD (impl, g_rw_lock_impl_cleanup);
+ g_cleanup_list_push (G_CLEANUP_LIST, (GCleanupFunc)g_rw_lock_impl_free, impl,
+ G_CLEANUP_PHASE_GRAVEYARD, G_STRFUNC);
else
g_rw_lock_impl_free (impl);
impl = lock->p;
@@ -694,12 +684,6 @@ g_cond_impl_free (pthread_cond_t *cond)
free (cond);
}
-static void
-g_cond_impl_cleanup (pthread_cond_t *impl)
-{
- G_CLEANUP_ADD (impl, g_cond_impl_free);
-}
-
static pthread_cond_t *
g_cond_get_impl (GCond *cond)
{
@@ -709,7 +693,8 @@ g_cond_get_impl (GCond *cond)
{
impl = g_cond_impl_new ();
if (g_atomic_pointer_compare_and_exchange (&cond->p, NULL, impl))
- G_CLEANUP_ADD (impl, g_cond_impl_cleanup);
+ g_cleanup_list_push (G_CLEANUP_LIST, (GCleanupFunc)g_cond_impl_free, impl,
+ G_CLEANUP_PHASE_GRAVEYARD, G_STRFUNC);
else
g_cond_impl_free (impl);
impl = cond->p;
@@ -1033,9 +1018,6 @@ g_private_cleanup (GPrivate *key)
if G_UNLIKELY ((status = pthread_setspecific (*impl, NULL)) != 0)
g_thread_abort (status, "pthread_setspecific");
-
- /* Cleanup as the very last thing */
- G_CLEANUP_ADD (impl, g_private_impl_free);
}
static pthread_key_t *
@@ -1048,7 +1030,10 @@ g_private_get_impl (GPrivate *key)
impl = g_private_impl_new (key->notify);
if (g_atomic_pointer_compare_and_exchange (&key->p, NULL, impl))
{
- G_CLEANUP_ADD (key, g_private_cleanup);
+ g_cleanup_list_push (key->cleanup, (GCleanupFunc)g_private_cleanup, key,
+ G_CLEANUP_PHASE_LATE, G_STRFUNC);
+ g_cleanup_list_push (key->cleanup, (GCleanupFunc)g_private_impl_free, impl,
+ G_CLEANUP_PHASE_GRAVEYARD, G_STRFUNC);
}
else
{
diff --git a/glib/gthread.h b/glib/gthread.h
index 43c7891..daed459 100644
--- a/glib/gthread.h
+++ b/glib/gthread.h
@@ -32,6 +32,7 @@
#endif
#include <glib/gatomic.h>
+#include <glib/gcleanup.h>
#include <glib/gerror.h>
G_BEGIN_DECLS
@@ -84,13 +85,14 @@ struct _GRecMutex
guint i[2];
};
-#define G_PRIVATE_INIT(notify) { NULL, (notify), { NULL, NULL } }
+#define G_PRIVATE_INIT(notify) { NULL, (notify), G_CLEANUP_LIST, { NULL } }
struct _GPrivate
{
/*< private >*/
gpointer p;
GDestroyNotify notify;
- gpointer future[2];
+ GCleanupList *cleanup;
+ gpointer future[1];
};
typedef enum
diff --git a/glib/gutils.c b/glib/gutils.c
index acebc12..183f5fe 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -797,9 +797,9 @@ g_get_user_database_entry (void)
if (!e.real_name)
e.real_name = g_strdup ("Unknown");
- G_CLEANUP_ADD (e.user_name, g_free);
- G_CLEANUP_ADD (e.real_name, g_free);
- G_CLEANUP_ADD (e.home_dir, g_free);
+ G_CLEANUP (e.user_name, g_free);
+ G_CLEANUP (e.real_name, g_free);
+ G_CLEANUP (e.home_dir, g_free);
g_once_init_leave (&entry, &e);
}
@@ -952,7 +952,7 @@ g_get_home_dir (void)
/* Only free this during cleanup if it's not from the user
* entry, because the user entry does its own freeing...
*/
- G_CLEANUP_ADD (tmp, g_free);
+ G_CLEANUP (tmp, g_free);
g_once_init_leave (&home_dir, tmp);
}
@@ -1018,7 +1018,7 @@ g_get_tmp_dir (void)
}
#endif /* !G_OS_WIN32 */
- G_CLEANUP_ADD (tmp, g_free);
+ G_CLEANUP (tmp, g_free);
g_once_init_leave (&tmp_dir, tmp);
}
@@ -1065,7 +1065,7 @@ g_get_host_name (void)
#endif
result = g_strdup (failed ? "localhost" : tmp);
- G_CLEANUP_ADD (result, g_free);
+ G_CLEANUP (result, g_free);
g_once_init_leave (&hostname, result);
}
@@ -1118,7 +1118,7 @@ g_get_prgname (void)
if (utf8_buf)
{
g_prgname = g_path_get_basename (utf8_buf);
- G_CLEANUP_ADD_FUNC (cleanup_prgname);
+ G_CLEANUP_FUNC (cleanup_prgname);
g_free (utf8_buf);
}
}
@@ -1148,7 +1148,7 @@ g_set_prgname (const gchar *prgname)
* during cleanup.
*/
if (!g_prgname)
- G_CLEANUP_ADD_FUNC (cleanup_prgname);
+ G_CLEANUP_FUNC (cleanup_prgname);
g_prgname = g_strdup (prgname);
G_UNLOCK (g_prgname);
}
@@ -1215,7 +1215,7 @@ g_set_application_name (const gchar *application_name)
else
{
g_application_name = g_strdup (application_name);
- G_CLEANUP_ADD (g_application_name, g_free);
+ G_CLEANUP (g_application_name, g_free);
}
G_UNLOCK (g_application_name);
@@ -1270,7 +1270,7 @@ g_get_user_data_dir (void)
data_dir = g_build_filename (g_get_tmp_dir (), g_get_user_name (), ".local", "share", NULL);
}
- G_CLEANUP_ADD (data_dir, g_free);
+ G_CLEANUP (data_dir, g_free);
g_user_data_dir = data_dir;
}
else
@@ -1306,7 +1306,7 @@ g_init_user_config_dir (void)
config_dir = g_build_filename (g_get_tmp_dir (), g_get_user_name (), ".config", NULL);
}
- G_CLEANUP_ADD (config_dir, g_free);
+ G_CLEANUP (config_dir, g_free);
g_user_config_dir = config_dir;
}
}
@@ -1389,7 +1389,7 @@ g_get_user_cache_dir (void)
else
cache_dir = g_build_filename (g_get_tmp_dir (), g_get_user_name (), ".cache", NULL);
}
- G_CLEANUP_ADD (cache_dir, g_free);
+ G_CLEANUP (cache_dir, g_free);
g_user_cache_dir = cache_dir;
}
else
@@ -1433,7 +1433,7 @@ g_get_user_runtime_dir (void)
{
runtime_dir = g_strdup (getenv ("XDG_RUNTIME_DIR"));
if (runtime_dir)
- G_CLEANUP_ADD (runtime_dir, g_free);
+ G_CLEANUP (runtime_dir, g_free);
g_once_init_leave (&initialised, 1);
}
@@ -1830,7 +1830,7 @@ g_get_user_special_dir (GUserDirectory directory)
if (G_UNLIKELY (g_user_special_dirs == NULL))
{
g_user_special_dirs = g_new0 (gchar *, G_USER_N_DIRECTORIES);
- G_CLEANUP_ADD_FUNC (cleanup_user_special_dirs);
+ G_CLEANUP_FUNC (cleanup_user_special_dirs);
load_user_special_dirs ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]