Move g_private_new() to common code
authorMatthias Clasen <mclasen@redhat.com>
Mon, 19 Sep 2011 01:24:25 +0000 (21:24 -0400)
committerRyan Lortie <desrt@desrt.ca>
Wed, 21 Sep 2011 20:06:54 +0000 (16:06 -0400)
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
glib/gthread-win32.c
glib/gthread.c

index ff5e5aa..c09a645 100644 (file)
@@ -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)
index 7910589..cc1dad3 100644 (file)
@@ -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)
index 9c591b5..6d731e8 100644 (file)
@@ -2438,3 +2438,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;
+}