[glib/wip/mutexes: 30/42] Move g_private_new() to common code
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/mutexes: 30/42] Move g_private_new() to common code
- Date: Mon, 19 Sep 2011 03:14:10 +0000 (UTC)
commit 4f54e5faac9a9acd535e7b2ef83fe473cb2cd9ac
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Sep 18 21:24:25 2011 -0400
Move g_private_new() to common code
The implementations for posix and win32 were identical, so
move it to gthread.c, to go with g_mutex_new() and g_cond_new().
glib/gthread-posix.c | 39 ---------------------------------------
glib/gthread-win32.c | 13 -------------
glib/gthread.c | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 52 deletions(-)
---
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index ff5e5aa..c09a645 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -387,45 +387,6 @@ g_cond_timedwait (GCond *cond,
/* {{{1 GPrivate */
-/**
- * g_private_new:
- * @destructor: a function to destroy the data keyed to
- * the #GPrivate when a thread ends
- *
- * Creates a new #GPrivate. If @destructor is non-%NULL, it is a
- * pointer to a destructor function. Whenever a thread ends and the
- * corresponding pointer keyed to this instance of #GPrivate is
- * non-%NULL, the destructor is called with this pointer as the
- * argument.
- *
- * <note><para>
- * #GStaticPrivate is a better choice for most uses.
- * </para></note>
- *
- * <note><para>@destructor is used quite differently from @notify in
- * g_static_private_set().</para></note>
- *
- * <note><para>A #GPrivate cannot be freed. Reuse it instead, if you
- * can, to avoid shortage, or use #GStaticPrivate.</para></note>
- *
- * <note><para>This function will abort if g_thread_init() has not been
- * called yet.</para></note>
- *
- * Returns: a newly allocated #GPrivate
- */
-GPrivate *
-g_private_new (GDestroyNotify notify)
-{
- GPrivate *key;
-
- key = malloc (sizeof (GPrivate));
- if G_UNLIKELY (key == NULL)
- g_thread_abort (errno, "malloc");
- g_private_init (key, notify);
-
- return key;
-}
-
void
g_private_init (GPrivate *key,
GDestroyNotify notify)
diff --git a/glib/gthread-win32.c b/glib/gthread-win32.c
index 7910589..cc1dad3 100644
--- a/glib/gthread-win32.c
+++ b/glib/gthread-win32.c
@@ -245,19 +245,6 @@ struct _GPrivateDestructor
static GPrivateDestructor * volatile g_private_destructors;
-GPrivate *
-g_private_new (GDestroyNotify notify)
-{
- GPrivate *key;
-
- key = malloc (sizeof (GPrivate));
- if G_UNLIKELY (key == NULL)
- g_thread_abort (errno, "malloc");
- g_private_init (key, notify);
-
- return key;
-}
-
void
g_private_init (GPrivate *key,
GDestroyNotify notify)
diff --git a/glib/gthread.c b/glib/gthread.c
index f59e46b..65d1868 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -2437,3 +2437,40 @@ g_cond_free (GCond *cond)
g_cond_clear (cond);
g_slice_free (GCond, cond);
}
+
+/**
+ * g_private_new:
+ * @destructor: a function to destroy the data keyed to
+ * the #GPrivate when a thread ends
+ *
+ * Creates a new #GPrivate. If @destructor is non-%NULL, it is a
+ * pointer to a destructor function. Whenever a thread ends and the
+ * corresponding pointer keyed to this instance of #GPrivate is
+ * non-%NULL, the destructor is called with this pointer as the
+ * argument.
+ *
+ * <note><para>
+ * #GStaticPrivate is a better choice for most uses.
+ * </para></note>
+ *
+ * <note><para>@destructor is used quite differently from @notify in
+ * g_static_private_set().</para></note>
+ *
+ * <note><para>A #GPrivate cannot be freed. Reuse it instead, if you
+ * can, to avoid shortage, or use #GStaticPrivate.</para></note>
+ *
+ * <note><para>This function will abort if g_thread_init() has not been
+ * called yet.</para></note>
+ *
+ * Returns: a newly allocated #GPrivate
+ */
+GPrivate *
+g_private_new (GDestroyNotify notify)
+{
+ GPrivate *key;
+
+ key = malloc (sizeof (GPrivate));
+ g_private_init (key, notify);
+
+ return key;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]